Merge lp:~zyga/checkbox/provider-manager-improvements into lp:checkbox

Proposed by Zygmunt Krynicki
Status: Work in progress
Proposed branch: lp:~zyga/checkbox/provider-manager-improvements
Merge into: lp:checkbox
Diff against target: 52 lines (+18/-5)
1 file modified
plainbox/plainbox/provider_manager.py (+18/-5)
To merge this branch: bzr merge lp:~zyga/checkbox/provider-manager-improvements
Reviewer Review Type Date Requested Status
Sylvain Pineau (community) Needs Information
Review via email: mp+244174@code.launchpad.net

Description of the change

99882ae plainbox:provider_manager: support i18n in manage_py_extension
ddfce85 plainbox:provider_manager: fix PEP-8 issue
24a9066 plainbox:provider_manager: fail gracefully in InstallCommand.get_command_epilog()

To post a comment you must log in.
Revision history for this message
Sylvain Pineau (sylvain-pineau) wrote :

How can I test rev 3487?

review: Needs Information
Revision history for this message
Zygmunt Krynicki (zyga) wrote :

Run the new regression provider with a polish locale, manage.py --help will show that run is now translated. You will have to run manage.py i18n first though.

Revision history for this message
Zygmunt Krynicki (zyga) wrote :

Bump, can we please have some feedback on this?

Revision history for this message
Sylvain Pineau (sylvain-pineau) wrote :

I ran:

$ PLAINBOX_I18N_MODE=lorem-ipsum-pl ./manage.py i18n
( cd po && intltool-update --gettext-package=plainbox-provider-checkbox-regressions --pot )
( cd po && intltool-update --gettext-package=plainbox-provider-checkbox-regressions --dist pl )
........... done.
6 translated messages, 5 fuzzy translations, 3 untranslated messages.
msgfmt po/pl.po -o build/mo/pl/LC_MESSAGES/plainbox-provider-checkbox-regressions.mo

##########################
And then the following manager command:

$ PLAINBOX_I18N_MODE=lorem-ipsum-pl ./manage.py --help
usage: <plainbox: bardzo.na [--albo] [--położył] [solwuję]>

<plainbox: Nie-ozdabiał utrzymanie poczuł>

positional arguments:
  {info,validate,develop,install,sdist,i18n,build,clean,run}
    info <plainbox:
    validate <plainbox:
    develop <plainbox:
    install <plainbox:
    sdist <plainbox:
    i18n <plainbox:
    build <plainbox:
    clean <plainbox:
    run <plainbox-provider-checkbox-regressions:

optional arguments:
  -h, --help show this help message and exit
  --version <plainbox: lecz dowiodę'i grządek będzie niż jako>

<plainbox: dowiodę tak przekradł>:
  -v, --verbose <plainbox: ją czuł stracił (dziś na --tak-bawić=PSÓW)>
  -D, --debug <plainbox: uparta TERAZ początek bo się lecz suwała>
  -C, --debug-console <plainbox: solwuję TERAZ sędziego na nie solwuję>
  -T <plainbox: CHARTY>, --trace <plainbox: CHARTY>
                        <plainbox: szybko TERAZ widziana po jak radziwiłł
                        pewnie (jak że lecz widziana lekki)>
  -P, --pdb <plainbox: czuł pali tak (charty ozdabiał) całe w
                        kłótnia zdrowie>
  -I, --debug-interrupt
                        <plainbox: brali na ZMRUŻA/Przedstawiając, bardzo było
                        --cię>

For me the run command is still empty, is that the expected output?

review: Needs Information
Revision history for this message
Zygmunt Krynicki (zyga) wrote :

Nope, I'll see what's going on there. Though I didn't use the loerm
ipsum mode. Thanks

On Mon, Jan 26, 2015 at 4:42 PM, Sylvain Pineau
<email address hidden> wrote:
> Review: Needs Information
>
> I ran:
>
> $ PLAINBOX_I18N_MODE=lorem-ipsum-pl ./manage.py i18n
> ( cd po && intltool-update --gettext-package=plainbox-provider-checkbox-regressions --pot )
> ( cd po && intltool-update --gettext-package=plainbox-provider-checkbox-regressions --dist pl )
> ........... done.
> 6 translated messages, 5 fuzzy translations, 3 untranslated messages.
> msgfmt po/pl.po -o build/mo/pl/LC_MESSAGES/plainbox-provider-checkbox-regressions.mo
>
> ##########################
> And then the following manager command:
>
> $ PLAINBOX_I18N_MODE=lorem-ipsum-pl ./manage.py --help
> usage: <plainbox: bardzo.na [--albo] [--położył] [solwuję]>
>
> <plainbox: Nie-ozdabiał utrzymanie poczuł>
>
> positional arguments:
> {info,validate,develop,install,sdist,i18n,build,clean,run}
> info <plainbox:
> validate <plainbox:
> develop <plainbox:
> install <plainbox:
> sdist <plainbox:
> i18n <plainbox:
> build <plainbox:
> clean <plainbox:
> run <plainbox-provider-checkbox-regressions:
>
> optional arguments:
> -h, --help show this help message and exit
> --version <plainbox: lecz dowiodę'i grządek będzie niż jako>
>
> <plainbox: dowiodę tak przekradł>:
> -v, --verbose <plainbox: ją czuł stracił (dziś na --tak-bawić=PSÓW)>
> -D, --debug <plainbox: uparta TERAZ początek bo się lecz suwała>
> -C, --debug-console <plainbox: solwuję TERAZ sędziego na nie solwuję>
> -T <plainbox: CHARTY>, --trace <plainbox: CHARTY>
> <plainbox: szybko TERAZ widziana po jak radziwiłł
> pewnie (jak że lecz widziana lekki)>
> -P, --pdb <plainbox: czuł pali tak (charty ozdabiał) całe w
> kłótnia zdrowie>
> -I, --debug-interrupt
> <plainbox: brali na ZMRUŻA/Przedstawiając, bardzo było
> --cię>
>
> For me the run command is still empty, is that the expected output?
> --
> https://code.launchpad.net/~zkrynicki/checkbox/provider-manager-improvements/+merge/244174
> You are the owner of lp:~zkrynicki/checkbox/provider-manager-improvements.

Unmerged revisions

3489. By Zygmunt Krynicki

plainbox:provider_manager: fail gracefully in InstallCommand.get_command_epilog()

This patch fixes an issue where InstallCommand would crash when plainbox
is started with PLAINBOX_I18N_MODE=lorem-ipsum-XX (e.g. lorem-ipsum-pl)
where a special trigger word would be faux-translated and a subsequent
lookup would fail.

Signed-off-by: Zygmunt Krynicki <email address hidden>

3488. By Zygmunt Krynicki

plainbox:provider_manager: fix PEP-8 issue

Signed-off-by: Zygmunt Krynicki <email address hidden>

3487. By Zygmunt Krynicki

plainbox:provider_manager: support i18n in manage_py_extension

This patch allows custom management commands to be correctly translated
by loading the provider-specific translation catalog early in the
initialization of the management tool.

Signed-off-by: Zygmunt Krynicki <email address hidden>

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plainbox/plainbox/provider_manager.py'
2--- plainbox/plainbox/provider_manager.py 2014-09-29 18:48:58 +0000
3+++ plainbox/plainbox/provider_manager.py 2014-12-09 16:27:56 +0000
4@@ -37,6 +37,7 @@
5 import tarfile
6
7 from plainbox import __version__ as version
8+from plainbox.i18n import bindtextdomain
9 from plainbox.i18n import docstring
10 from plainbox.i18n import gettext as _
11 from plainbox.i18n import gettext_noop as N_
12@@ -225,10 +226,13 @@
13 ' * {:10} => {}'.format(src, dest)
14 for src, dest in sorted(layout.items())
15 )
16- return re.sub(
17- '@LAYOUT\[(\w+)]@',
18- lambda m: format_layout(self._INSTALL_LAYOUT[m.group(1)]),
19- super().get_command_epilog())
20+ try:
21+ return re.sub(
22+ '@LAYOUT\[(\w+)]@',
23+ lambda m: format_layout(self._INSTALL_LAYOUT[m.group(1)]),
24+ super().get_command_epilog())
25+ except:
26+ return super().get_command_epilog()
27
28 def register_parser(self, subparsers):
29 """
30@@ -1030,7 +1034,8 @@
31 provider_list = all_providers.get_all_plugin_objects()
32 if all(p.name != provider.name for p in provider_list):
33 provider_list.append(provider)
34- # Add the built-in 'categories' provider, unless that's the one we're testing
35+ # Add the built-in 'categories' provider, unless that's the one we're
36+ # testing
37 categories_provider = get_categories()
38 if provider.base_dir != categories_provider.base_dir:
39 provider_list.append(categories_provider)
40@@ -1403,6 +1408,14 @@
41 raise SystemExit(_("{}: bad value of {!r}, {}").format(
42 manage_py, exc.variable.name, exc.message))
43 else:
44+ # Install provider's i18n, if possible, this makes management
45+ # extensions localizable as long as they use the same gettext
46+ # domain name.
47+ if (definition.effective_gettext_domain
48+ and definition.effective_locale_dir):
49+ bindtextdomain(
50+ definition.effective_gettext_domain,
51+ definition.effective_locale_dir)
52 raise SystemExit(ProviderManagerTool(definition, kwargs).main())
53
54

Subscribers

People subscribed via source and target branches