Locale Translations (#7) - FlexCat - .po to .ct? (#116) - Message List

FlexCat - .po to .ct?
 unsolved

I was checking out FlexCat (2.15) to see if I could make it produce a .ct file out of the .po file from Transifex. I tried "flexcat POFILE for_translation_yam_trunk_da.po NEWCTFILE yam.ct", and while it did tell me about the strings missing in the translation, it did not result in a .ct file (well, not a usable one, anyway, only the headers were there).

Can anybody tell me whether this is possible yet in FlexCat, and if so, how?

Best regards,

Niels

  • Message #426

    I was checking out FlexCat (2.15) to see if I could make it produce a .ct file out of the .po file from Transifex. I tried "flexcat POFILE for_translation_yam_trunk_da.po NEWCTFILE yam.ct", and while it did tell me about the strings missing in the translation, it did not result in a .ct file (well, not a usable one, anyway, only the headers were there).

    Can anybody tell me whether this is possible yet in FlexCat, and if so, how?

    This is currently not supported (yet).

    Although we have a script convert .po files into .ct files and vice versa which Jens used to initially convert the old .ct files to the new .po format this script requires a Unix system to do its work. Furthermore the script does certain assumptions about the file contents might screw up everything if these assumptions do not hold.

    To make it short: better use the services of Transifex to do your translation. The translations will be synced automatically every hour, so in average it takes approx. half an hour to get your updated translation into the repository.

    If you think that such a conversion between the format is really absolutely necessary then please open an enhancement request in FlexCat's bugtracker at sourceforge.net to ensure that it is not forgotten.

    • Message #444

      Hi Thore,

      sorry to wake up such an old thread. This is Steffen with the MUIbase application. I am in a similar situation regarding CD/CT/PO files. Currently I have translations in CT files, and, for Windows/OSX/Unix use a hand-written tool for converting them to PO files such that gettext et al. is happy.

      I am about to change this such that all translations are in PO files (easier to handle, UTF-8, etc.) and want to generate the CT files (for the Amiga version) from the PO files. That converter is also not hard two write, but I am just wondering if you are willing to share your experience and/or code for this?

      In my case I am Unix-based since a long time (10+ years) and cross-compile all stuff for Amiga/PPC/MorphOS.

      • Message #445

        I am about to change this such that all translations are in PO files (easier to handle, UTF-8, etc.) and want to generate the CT files (for the Amiga version) from the PO files. That converter is also not hard two write, but I am just wondering if you are willing to share your experience and/or code for this?

        Jens already has done such a converter, for both directions. But AFAIK he mainly used it to convert from .ct to .po as we switched all our projects to .po files only. These definitely cause much less headaches when it comes to languages like russian, greek, etc, which have more non-latin characters than plain latin characters. The .po file format is able to handle all those characters correctly by being UTF8 by default instead of implying certain code sets and even worse special fonts to display them correctly with ISO8859-1.

        In my case I am Unix-based since a long time (10+ years) and cross-compile all stuff for Amiga/PPC/MorphOS.

        We enhanced FlexCat a lot to operate on .po files and create .catalog files correct strings and encodings. If you prefer to use the .po files direcly this is your choice. But I really recommend to direct your translators to Transifex which offers a very good web based frontend for translation.

        The times of specially encoded .ct files are over. UTF8 rules the world.

        • Message #446

          I am about to change this such that all translations are in PO files (easier to handle, UTF-8, etc.) and want to generate the CT files (for the Amiga version) from the PO files. That converter is also not hard two write, but I am just wondering if you are willing to share your experience and/or code for this?

          Jens already has done such a converter, for both directions. But AFAIK he mainly used it to convert from .ct to .po as we switched all our projects to .po files only.

          Exactly. Back then I wrote myself a long by rather simple bash script that performs all the basic conversion for our various .cd and .ct files and convert them to proper .po and .pot files. If you need that tool I just put it back into our repository again. See here:

          https://github.com/jens-maus/yam/blob/master/scripts/cd2po.sh

          As said, this is a rather simple but efficient tool. And Thore is of course correct that directly using .po and .pot files together with FlexCat should be the way to go!

          • Message #448

            Thanks for the prompt answers!

            The main take-away I see here is that flexcat can read po files and do all the conversions (including text encoding). That's a big plus!

            I have also written some converters (it's a simple enough exercise) and sources are here: https://sourceforge.net/p/muibase/code/HEAD/tree/trunk/src/tools/

            I still need to adjust these a bit to match the po-format that flexcat expects. From some experiments I found that:

            1. The version is given in a single "# version XX" line somewhere at the top of the PO file.
            2. The MsgId's are given as msgctxt, e.g. "msgtxt "MSG_OK ()"".

            In my POT file, I left the translations empty (msgstr is ""), since, I believe, this is the convention for the PO template. Flexcat complains about this, and I think it shouldn't, when generating the c/h files.

          • Message #447

            Thanks for the prompt answers!

            The main take-away I see here is that flexcat can read po files and do all the conversions (including text encoding). That's a big plus!

            I have also written some converters (it's a simple enough exercise) and sources are here: https://sourceforge.net/p/muibase/code/HEAD/tree/trunk/src/tools/

            I still need to adjust these a bit to match the po-format that flexcat expects. From some experiments I found that:

            1. The version is given in a single "# version XX" line somewhere at the top of the PO file.
            2. The MsgId's are given as msgctxt, e.g. "msgtxt "MSG_OK ()"".

            In my POT file, I left the translations empty (msgstr is ""), since, I believe, this is the convention for the PO template. Flexcat complains about this, and I think it shouldn't, when generating the c/h files.

            • Message #449

              The main take-away I see here is that flexcat can read po files and do all the conversions (including text encoding). That's a big plus!

              I have also written some converters (it's a simple enough exercise) and sources are here: https://sourceforge.net/p/muibase/code/HEAD/tree/trunk/src/tools/

              Wow, you have taken the task to do such a conversion tool in C/C++. This is really brave because I think such text based conversion are really better done using scripting languages like bash scripts or even python but not using C which IMHO is totally overkill. But well, everyone prefers something else.

              I still need to adjust these a bit to match the po-format that flexcat expects. From some experiments I found that:

              1. The version is given in a single "# version XX" line somewhere at the top of the PO file.

              Exactly. But with the latest version of FlexCat (not released yet) you can also omit these lines but simply specify the version on the command-line when you execute flexcat. This is how we are doing it with YAM, etc. now that we have moved to github.

              1. The MsgId's are given as msgctxt, e.g. "msgtxt "MSG_OK ()"".

              That's exactly how I defined this conversion and so far it works really quite well. See here for the YAM.pot file: https://github.com/jens-maus/yam/blob/master/locale/YAM.pot

              In my POT file, I left the translations empty (msgstr is ""), since, I believe, this is the convention for the PO template. Flexcat complains about this, and I think it shouldn't, when generating the c/h files.

              It actually should and is correct to complain because that's the way pot files should usually be defined so that translation programs automatically come up with the english word/sentence which you are going to translate then. Quite a while ago when I added this this was due to Transifex (which is very nice and handy and which we used for cloud-based translation support – use it as well! – see https://www.transifex.com/ato/) required this to actually showing the english strings correctly for being translated afterwards. So please go the same road and design your .pot files so that msgid and msgstr contain exactly the same string even if this looks odd to you :)

              • Message #450

                The gettext manual (e.g. https://www.gnu.org/software/gettext/manual/html_node/index.html#Top) does not clearly specify what the msgstr value should be for a PO template. However, several sources hint towards an empty string. See e.g. https://www.drupal.org/node/1814954.

                Also, whey running the xgettext program, the msgstr entries are empty strings, e.g:

                steffen@westin:/tmp$ cat test.c
                char test[] = _("Test");
                steffen@westin:/tmp$ xgettext test.c
                steffen@westin:/tmp$ cat messages.po
                # SOME DESCRIPTIVE TITLE.
                # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
                # This file is distributed under the same license as the PACKAGE package.
                # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
                #
                #, fuzzy
                msgid ""
                msgstr ""
                "Project-Id-Version: PACKAGE VERSION\n"
                "Report-Msgid-Bugs-To: \n"
                "POT-Creation-Date: 2016-06-09 22:21-0700\n"
                "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
                "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
                "Language-Team: LANGUAGE <LL@li.org>\n"
                "Language: \n"
                "MIME-Version: 1.0\n"
                "Content-Type: text/plain; charset=CHARSET\n"
                "Content-Transfer-Encoding: 8bit\n"
                #: test.c:2
                msgid "Test"
                msgstr ""
                

                I was planning of using a POT file as the basis of all translatable text. Requiring msgid and msgstr to being identical is not very pratical as one always needs to edit both strings or copy & paste them.

                Well, for now I can ignore the flexcat warnings when converting a PO file to the c/h sources. It really only makes sense to warn about missing translations when processing the actual translations (PO -> Amiga-style catalog).

                Is there a chance to at least adding a flag to suppress these warnings, e.g. similar to WARNCTGAPS?

                • Message #452

                  The gettext manual (e.g. https://www.gnu.org/software/gettext/manual/html_node/index.html#Top) does not clearly specify what the msgstr value should be for a PO template. However, several sources hint towards an empty string. See e.g. https://www.drupal.org/node/1814954.

                  Also, whey running the xgettext program, the msgstr entries are empty strings, e.g:

                  [...]

                  Of course, if you look up the specs and how po files are usually used on other platforms situation might be different. But we are using/defining an adapted version for our Amiga purposes because we require msgctxt to be used adequately or flexcat cannot convert these files properly to *.catalog files. The same more or less applies for *.pot files here I would say.

                  And then you are also not using gettext at all but FlexCat here and without msgctxt setup correctly in the traditional ct-like format FlexCat would also not be able to convert these strings properly.

                  I was planning of using a POT file as the basis of all translatable text. Requiring msgid and msgstr to being identical is not very pratical as one always needs to edit both strings or copy & paste them.

                  That's not the case. See here for the german YAM translation: https://github.com/jens-maus/yam/blob/master/locale/german.po

                  As you will see there only the msgstr will contain the german translation, the "msgid" will always stay at the english text as exactly stated in the *.pot file. However, as I said before, Transifex requires to also have "msgstr" being set to a non-empty string or otherwise it won't display the english text for translation purposes. And then in the end it is just a matter of duplicating the msgid string to msgstr for the sake of having the *.pot file compatible to FlexCat. In the end the translator only has to translate "msgstr" and can easily do so by replacing the string while he is translating it. From my point of view this also provides some sort of help text while translating text.

                  Well, for now I can ignore the flexcat warnings when converting a PO file to the c/h sources. It really only makes sense to warn about missing translations when processing the actual translations (PO -> Amiga-style catalog). Is there a chance to at least adding a flag to suppress these warnings, e.g. similar to WARNCTGAPS?

                  Of course we could add options for everything and everyone, but then I would say these are warnings anyway which you don't have to care about much. And again, adding the same string from "msgid" to "msgstr" really don't hurt - especially if you anyway going to use transifex which IMHO you should anyway do in future.

                  • Message #453

                    Actually, the QUIET keyword already allows to suppress these warnings. But one needs to specify QUIET before the PO/POT file on the command line in order to have this effect, which somewhat contradicts the information given by the HELP output. The reason for this is that flexcat is reading the PO/POT file (and likewise a CD file) before parsing the full command line, thus the QUIET keyword is not in effect yet when reading the file. Maybe change the HELP output, or fully parse the command line first before processing the input.

                    Also, a warning like "missing translation for identifier" sets the return code to 5. Looking at the flexcat source there are other places where the program exist with this error code and these are real errors (e.g. Usage). I suggest to make warnings return a smaller return code, and when QUIET is set, not to change the return code.

                    • Message #454

                      You are absolutely right that the cmdline options parsing in flexcat is a mess for the unix version, which isbsimply because it had been implemented quite quickly trying to mimic the behaviour of ReadArgs of AmigaOS, which simply doesn't fit how unix cmdline parsing usually works. I recently stumbled over this myself any recognized that the order of cmdline options matter quite strongly, but I refused to reimplement the whole thing due to time constraints. But if you have the time and motivation please feel free to reimplement this youself and send a pull request along our way (https://github.com/adtools/flexcat) or I could also add you to our adtools project so that you will have direct write access to the repository. So your help would be definitly appreciated!

              • Message #451

                (Deleted duplicate message)

Attachments

No attachments created.