Skip to content

A blazing fast CLI program to compile GNU gettext .po file to binary .mo format.

License

Notifications You must be signed in to change notification settings

BrettDong/compile-po2mo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

compile-po2mo

License: MIT GitHub Actions

A blazing fast CLI program to compile GNU gettext .po file to binary .mo format.

Usage

Compile a single .po file to .mo

$ compile-po2mo input.po output.mo

Compile a batch of .po files in parallel

Use path patterns denoted by <lang>:

$ compile-po2mo "./i18n/translations/<lang>.po" "./build/i18n/<lang>/LC_MESSAGES/app.mo"

All .po files matching the pattern will be compiled to the destination path:

./i18n/translations/ja.po => ./build/i18n/ja/LC_MESSAGES/app.mo
./i18n/translations/es_ES.po => ./build/i18n/es_ES/LC_MESSAGES/app.mo
...

Be noted that on UNIX shell the path pattern has to be quoted, otherwise < and > symbols are interpreted as redirection by the shell.

Use on GitHub Actions

I have prepared an action to use this tool to compile translations in GNU gettext format as a step in your CI/CD workflow on GitHub Actions:

  - name: Compile translations
    uses: BrettDong/compile-po2mo-action@v1
    with:
        input-path: 'lang/po/<lang>.po'
        output-path: 'lang/mo/<lang>/LC_MESSAGES/app.mo'

Visit http://github.com/BrettDong/compile-po2mo-action for details.

Limitation / Caveat

  • Only supports UTF-8 encoding

  • Does not check input .po data on C format string correctness, duplicate entries, etc.

The program may panic or silently produce nonsense output when input data is ill-formed. You should only use this tool when all input data is trusted and valid, and you want to cut down project build times and CI/CD costs.

Benchmark

Detailed logs can be viewed at https://github.com/BrettDong/compile-po2mo/actions/runs/1757459199 .

Time to compile all translations to 36 languages on GitHub Actions runners:

GitHub Actions Host Method Parallelism Time
Windows Server 2019 msgfmt dual-core 30.157s
Windows Server 2019 compile-po2mo dual-core 1.908s
Ubuntu Linux 20.04 msgfmt dual-core 16.950s
Ubuntu Linux 20.04 compile-po2mo dual-core 1.050s
macOS 10.15 msgfmt tri-core 11.270s
macOS 10.15 compile-po2mo tri-core 1.231s

About

A blazing fast CLI program to compile GNU gettext .po file to binary .mo format.

Topics

Resources

License

Stars

Watchers

Forks

Languages