Closed Bug 783202 Opened 12 years ago Closed 12 years ago

Make l10n_utils.dotlang._ able to extract strings to specific file


( :: Bedrock, defect, P2)



(Not tracked)



(Reporter: Milos, Assigned: pmac)


(Blocks 1 open bug)


(Whiteboard: u=localizer c=l10n p=2)

Currently, our l10n_utils.dotlang._ method extract strings straight into main.lang files. We'd need that method to accept another parameter to pick which .lang file we want the string to be extracted to.
To make the request clearer, we can define in a template which .lang file to use for a page, for example {% add_lang_files "whatsnew" %}. But there are strings that are not part of a template because they are not in a pure web context (email strings for example), and then bedrock falls back to main.lang which is not what we want.
Component: → General
Product: Websites →
ok, this bug is actually impacting our work on the contribute page, we are currently targetting a few locales until we feel confortable going large scale (that means having a native speaker per locale volunteering to manage incoming form requests, so that will be gradual) and currently the strings for the contact form are extracted into main.lang shared by all locales, sending the signal to localizers that we are ready to have that page in 90 languages, which I don't think is realistic as of today :).

CCing Ben,
Ben could we put this bug into the next sprint?  Thanks
Blocks: 755351
Whiteboard: u=localizer c=l10n p=2 [sb-sprint]
Component: General → L10N
Summary: [bedrock] Make l10n_utils.dotlang._ able to extract strings to specific file → Make l10n_utils.dotlang._ able to extract strings to specific file
Component: L10N → Bedrock
Assignee: nobody → pmac
Priority: -- → P2
Would you want to specify this per call to `_()`, or would it be better to be able to specify per python file, like with a function call `set_lang_file('blah')` at the top of the file?
ideally both ? ;) But setting that at the top of a python file would already be a great step forward.
Whiteboard: u=localizer c=l10n p=2 [sb-sprint] → u=localizer c=l10n p=2

This adds the ability to add a `LANG_FILES` constant to python files that will work like the `add_lang_files` tag in templates. The value can be a single name (e.g. 'firefoxos') or a list of strings (e.g. ['firefoxos', 'b2g']). The docs are updated with more info.

It turned out that adding an extra argument to the `_` function was impossible without patching multiple external libraries. I think this works better anyway.
Blocks: 797984
Component: Bedrock → L10N
Component: L10N → Bedrock
Commit pushed to master at
Add ability to specify lang files in python src.

* Fix bug 783202.
* Update docs.
Closed: 12 years ago
Resolution: --- → FIXED
Commit pushed to master at
Use SkipTest from nose as skip is only in Py 2.7+.

bug 783202.
awesome, thanks pmac ! :)
You need to log in before you can comment on or make changes to this bug.