Skip to content

Improve indico i18n CLI to support plugin-related i18n operations #5961

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Nov 17, 2023

Conversation

SegiNyn
Copy link
Contributor

@SegiNyn SegiNyn commented Sep 29, 2023

Indico i18n Improvements

Closes #5906
The commands look like this:

(indico-un) (base) segilolamustapha@Segilolas-MacBook-Pro indico % indico i18n --help
Usage: indico i18n [OPTIONS] COMMAND [ARGS]...

  Perform i18n-related operations.

Options:
  --help  Show this message and exit.

Commands:
  check-format-strings  Check whether format strings match.
  compile               Catalog compilation command for indico and indico
                        plugins.
  extract               Message extraction command for indico and indico
                        plugins.
  init                  New catalog initialization command for indico and
                        indico plugins.
  pull                  Pull translated .po files from Transifex.
  push                  Push .pot files to Transifex.
  update                Catalog merging command for indico and indico plugins.

As seen above, commands are grouped by the operation to be performed, init, extract, update and compile

Furthermore, indico i18n compile --help shows we can pass either indico, plugins or all-plugins

indico is to perform the operation on indico

plugins is to perform the operation on the given plugin paths

all-plugins is to perform the operation on a directory containing multiple plugins

(indico-un) (base) segilolamustapha@Segilolas-MacBook-Pro indico % indico i18n compile --help
Usage: indico i18n compile [OPTIONS] COMMAND [ARGS]...

  Catalog compilation command for indico and indico plugins.

Options:
  --help  Show this message and exit.

Commands:
  all-plugins  Perform compile_catalog operation on all-plugins
  indico       Perform compile_catalog operation on indico
  plugins      Perform compile_catalog operation on plugins

Running the command like that e..g indico i18n compile indico would apply for python, javascript and react. If you want to specify a resource then pass the flag --python, --javascript, --react.

(indico-un) (base) segilolamustapha@Segilolas-MacBook-Pro indico % indico i18n compile indico --help
Usage: indico i18n compile indico [OPTIONS]

Options:
  --no-check  Skip running the string format validation.
  --react     i18n used in react code.
  --python    i18n used in python and Jinja code.
  --help      Show this message and exit.

As seen above, there is also a --no-check option for the compilation command.
The extract and update commands are pretty much the same with the exception that they allow the --javascript flag and do not have a --no-check option.

The init command requires an additional locale argument and can be used like this:

indico i18n init indico --locale pt_PT

In addition, there is now a pull and push command to pull and push from Transifex. This only applies to Indico translations on transifex.

indico i18n push
indico i18n pull 
indico i18n pull fr_FR pt_PT

The pull command can take in languages as argument to pull only those specific languages and performs the language code rename.

Plugins

The command for the plugins are the same as above, except that you specify plugins or all-plugins instead of indico and also pass in the plugin path

(indico-un) (base) segilolamustapha@Segilolas-MacBook-Pro indico % indico i18n compile plugins --help
Usage: indico i18n compile plugins [OPTIONS] PLUGIN_DIRS...

Options:
  --no-check  Skip running the string format validation.
  --react     i18n used in react code.
  --python    i18n used in python and Jinja code.
  --help      Show this message and exit.

Can be used like:

indico i18n extract plugins <plugin_dirs>

You can also target only --python, --javascript or --react
e.g

indico i18n extract plugins --javascript <plugin_dirs>  # here plugin_dirs is one or multiple plugin directories

The same applies to all-plugins e.g.

indico i18n update all-plugins --react <plugin_dirs>  # here plugin_dirs is a single directory containing multiple plugins

So for your common operations, you would most likely only need to do:

indico i18n extract indico; indico i18n push;

and then

indico i18n pull; indico i18n compile indico;   # pass --no-check flag to skip the check_format_string

@SegiNyn SegiNyn force-pushed the i18n-improvements branch 3 times, most recently from 3471225 to 3daa79c Compare September 29, 2023 12:29
@SegiNyn SegiNyn force-pushed the i18n-improvements branch 2 times, most recently from 43e77b0 to 44c05bd Compare October 4, 2023 19:35
@SegiNyn SegiNyn requested review from ThiefMaster and tomasr8 October 5, 2023 07:56
@SegiNyn SegiNyn force-pushed the i18n-improvements branch 2 times, most recently from ca77ce3 to 11538dd Compare October 17, 2023 07:29
@SegiNyn SegiNyn force-pushed the i18n-improvements branch 2 times, most recently from e31c0f3 to 0a5d768 Compare October 20, 2023 12:20
Copy link
Member

@tomasr8 tomasr8 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@ThiefMaster
Copy link
Member

Is pulling/pushing for plugins not supported on purpose?

@ThiefMaster
Copy link
Member

Compiling plugin resources doesn't seem to work at all.

To reproduce:

  • Run tx pull -f -l it_IT in the indico plugins directory
  • Run indico i18n compile plugins ../plugins/public/vc_zoom/ (same problem with all-plugins btw)
  • Run ls vc_zoom/indico_vc_zoom/translations/it_IT/LC_MESSAGES/ - there's no messages.mo file!

@SegiNyn
Copy link
Contributor Author

SegiNyn commented Oct 30, 2023

Compiling plugin resources doesn't seem to work at all.

This is odd, do you have .po files for that plugin?

@ThiefMaster
Copy link
Member

yes, i freshly fetched them from transifex

@SegiNyn
Copy link
Contributor Author

SegiNyn commented Nov 1, 2023

Changes made:

  1. Changed plugins command to plugin
  2. Allow passing an optional locale for the compile and update commands. The locale remains mandatory for init and None for extract
  3. Delete empty .pot files after extraction
  4. Allow push and pull from transifex for plugins as well.
    So the command for pushing is now:
indico i18n push indico
indico i18n push plugin <plugin_dir>
indico i18n push all-plugins <plugins_dir>

and

indico i18n pull indico 
indico i18n pull plugin <plugin_dir>
indico i18n pull all-plugins <plugins_dir>

Language to pull can also be passed like

indico i18n pull indico it_IT

The command push/pull for all-plugins uses the transifex config file in the all-plugins directory. But for the command to work for a single plugin, add the configuration file directly for that plugin in a .tx/config file. For example:

[main]
host = https://www.transifex.com

[o:indico:p:indico:r:vc-zoom-messages]
file_filter = indico_vc_zoom/translations/<lang>/LC_MESSAGES/messages.po
source_file = indico_vc_zoom/translations/messages.pot
source_lang = en
type = PO

[o:indico:p:indico:r:vc-zoom-messages-js]
file_filter = indico_vc_zoom/translations/<lang>/LC_MESSAGES/messages-js.po
source_file = indico_vc_zoom/translations/messages-js.pot
source_lang = en
type = PO

Copy link
Member

@ThiefMaster ThiefMaster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WTF, not sure why i never submitted these review comments...

@SegiNyn SegiNyn changed the title Improve indico i18n cli and add i18n cli support for plugins Improve indico i18n CLI to support plugin-related i18n operations Nov 14, 2023
@SegiNyn SegiNyn requested a review from ThiefMaster November 16, 2023 08:49
@ThiefMaster ThiefMaster added this to the v3.3 milestone Nov 17, 2023
@ThiefMaster ThiefMaster merged commit 0abd1ed into indico:master Nov 17, 2023
@ThiefMaster ThiefMaster deleted the i18n-improvements branch November 17, 2023 10:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

indico i18n CLI improvements
3 participants