denise: Image: Me, facing away from camera, on top of the Castel Sant'Angelo in Rome (Default)
Denise ([staff profile] denise) wrote in [site community profile] dw_dev_training2011-08-19 12:07 pm

*bangs head against translation system*

Scenario: I have a dw-nonfree file (cgi-bin/DW/Hooks/Community.pm) in which I want to reference text that is a mixture of both en_DW.dat (dw-nonfree version) and FAQs from en.dat (dw-free version). (Namely: I am referencing FAQs in the code, and would like the FAQ titles to automatically update in the page if they update on the site.)

I thought this would work:



However, although I do have a FAQ #17 on my 'hack, it comes up as:

[missing string 17.1question]

I'm suspecting it's because I need to declare the 'faq' scope instead of the 'general' scope, but can I intermingle things from faq and general? Is there an easier way to be doing what I want to do?
sophie: A cartoon-like representation of a girl standing on a hill, with brown hair, blue eyes, a flowery top, and blue skirt. ☀ (Default)

[personal profile] sophie 2011-08-19 05:03 pm (UTC)(link)
The FAQ pages seem do to do it by loading the LJ::Faq object and then getting it from there. Something like this might work (although I don't think this will respect the user's language settings - not that we have any different languages on this site, but other sites might):

my $faq = LJ::Faq->load( 17 );
$ret .= "<li><a href='blah'>" . $faq->question_html . "</a></li>";


If you want languages respected, then this is probably the right way to do it (with the first half of this pretty much directly copied from htdocs/support/faqbrowse.bml; the only thing I edited was taking away the detection of the ?lang= URL parameter):

# get language settings
my $curlang = BML::get_language();
my $deflang = BML::get_language_default();
my $altlang = $curlang ne $deflang;
my $mll = LJ::Lang::get_lang($curlang);
my $mld = LJ::Lang::get_dom("faq");
$altlang = 0 unless $mll && $mld;
my $lang = $altlang ? $curlang : $deflang;

my $faq = LJ::Faq->load( 17, lang => $lang );
$ret .= "<li><a href='blah'>" . $faq->question_html . "</a></li>";


Oh, you may want to make sure $faq actually exists too, thinking about it; if the FAQ isn't there then that code would fail when it tries to access 'question_html'.
Edited (Escaping HTML is a good thing. So are languages. And getting arguments right.) 2011-08-19 17:11 (UTC)
pauamma: Cartooney crab wearing hot pink and acid green facemask holding drink with straw (Default)

[personal profile] pauamma 2011-08-19 05:46 pm (UTC)(link)
Hmm. This should work, but I vaguely remember that sometimes FAQs wouldn't exist as translatable strings. Run this:
$LJHOME/bin/upgrading/texttool.pl copyfaq
and try again.
pauamma: Cartooney crab wearing hot pink and acid green facemask holding drink with straw (Default)

[personal profile] pauamma 2011-08-19 06:40 pm (UTC)(link)
I think it might be time to take a break and go read some fic instead :P
Yeah, probably. Or have some sleep. It works wonder for my own sanity. (No comments from the peanut gallery.)

Anyway, when you start working on it again, I'd like to poke at your dreahack a bit more, because there's something not quite right.
pauamma: Cartooney crab wearing hot pink and acid green facemask holding drink with straw (Default)

[personal profile] pauamma 2011-08-20 01:20 pm (UTC)(link)
OK, I'm an idiot. Once http://bugs.dwscoalition.org/show_bug.cgi?id=3833 is fixed, your first method should work on your dreamhack. (And would probably work on production servers now.)
sophie: A cartoon-like representation of a girl standing on a hill, with brown hair, blue eyes, a flowery top, and blue skirt. ☀ (Default)

[personal profile] sophie 2011-08-20 02:43 pm (UTC)(link)
Are you sure? Rah does actually have FAQs on her server, including an FAQ #17. (They're not the production FAQs, obviously, but she does have data there.)
Edited 2011-08-20 14:43 (UTC)
pauamma: Cartooney crab wearing hot pink and acid green facemask holding drink with straw (Default)

[personal profile] pauamma 2011-08-20 03:03 pm (UTC)(link)
She has them in the faqs table, but I'm just about sure she doesn't have them in the ml_* tables, because they're not in en.dat or en_DW.dat, which is what \normally populates those tables. I'm not sure why copyfaqs didn't do the trick, though. Maybe memcache was interfering?
sophie: A cartoon-like representation of a girl standing on a hill, with brown hair, blue eyes, a flowery top, and blue skirt. ☀ (Default)

[personal profile] sophie 2011-08-20 03:20 pm (UTC)(link)
Hmm. I'll bow out of the conversation here since I don't know much about how FAQs and the translation system worked, except to say that I was fairly sure you needed to use the "faq" domain for that sort of thing?
pauamma: Cartooney crab wearing hot pink and acid green facemask holding drink with straw (Default)

[personal profile] pauamma 2011-08-20 03:25 pm (UTC)(link)
Hmm, yeah. We can probably revisit this once FAQ text makes it to the repo.