Coder Social home page Coder Social logo

pomerger's Introduction

PO Merger

This application is for the specific purpose of merging GetText Portable Object (PO) files. You are expected to have one base file which has all the translation keys (let's say it's in English and called en.po) , and another file which has (at least) some keys translated to some other language (let's say Finnish, fi.po).

This application takes both of those files as input and generates a new file (output.po) which has all the same keys as the base file (en.po) but amended with the translations from the other file. This way, when your en.po receives new translation keys, you can use this application to add those keys into other translation files as well -- no matter where in the file the new translations have been added, and without worrying about losing the existing translations you already have. This should be handy when your translation file contains hundreds or even thousands of strings. After the output.po file has been created, you may inspect it manually and just copy it over the other translation file (so that it becomes the new fi.po).

Example

A base PO file (entered as input for this application) may have any number of entries -- three in this example:

#. "MAIN_MENU[SAVE]"
msgid "Save"
msgstr ""
#. "MAIN_MENU[OPEN]"
msgid "Open"
msgstr ""
#. "MAIN_MENU[CLOSE]"
msgid "Close"
msgstr ""

"msgid" is the untranslated version of the string, or the "base" text, and "msgstr" is the translation. Thus the base file does not need any "msgstr" string in it.

Now, let's say your fi.po has a couple of those strings translated:

#. "MAIN_MENU[SAVE]"
msgid "Save"
msgstr "Tallenna"
#. "MAIN_MENU[OPEN]"
msgid "Open"
msgstr ""
#. "MAIN_MENU[CLOSE]"
msgid "Close"
msgstr "Sulje"

Then, your application is changed and a couple of new entries are added to en.po:

#. "MAIN_MENU[SAVE]"
msgid "Save"
msgstr ""
#. "MAIN_MENU[SAVE_AS]"
msgid "Save as"
msgstr ""
#. "MAIN_MENU[OPEN]"
msgid "Open"
msgstr ""
#. "MAIN_MENU[RELOAD]"
msgid "Reload"
msgstr ""
#. "MAIN_MENU[CLOSE]"
msgid "Close"
msgstr ""

Now, you would run this application to merge the new translation keys with your existing translations and the application would give you an output with some statistics about the process:

Untranslated file has 5 entries (15 lines)
Translated file has 3 entries (9 lines), 2 of them translated (67%)
Untranslated file has 5 unique comments which is as it should be.
Untranslated file confirmed to have all the keys that are already in the translated file.
Joining the missing entries into the translation file...
Writing 5 entries (15 lines) (40% translated) to ~\output.po...
All done in 25 ms.

Yielding the following output file:

#. "MAIN_MENU[SAVE]"
msgid "Save"
msgstr "Tallenna"
#. "MAIN_MENU[SAVE_AS]"
msgid "Save as"
msgstr ""
#. "MAIN_MENU[OPEN]"
msgid "Open"
msgstr ""
#. "MAIN_MENU[RELOAD]"
msgid "Reload"
msgstr ""
#. "MAIN_MENU[CLOSE]"
msgid "Close"
msgstr "Sulje"

Limitations

Currently this application only supports PO files where each entry also has a comment, like in the examples above (the lines starting with #). These comments are used as the unique keys for the translations. There are, however, no other limitations to the format of the comments, as long as they are unique and start with a #.

Technical details

Requires Java 18 but no external libraries.

pomerger's People

Contributors

zeroone3010 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.