Code Monkey home page Code Monkey logo

Comments (10)

iafan avatar iafan commented on August 30, 2024 1

It's likely that Serge simply can't execute your prepare.sh. Try specifying a full path to prepare.sh, make sure it can actually be executed (has the necessary executable bit, ownership and a shebang line).

It might be also that prepare.sh is actually executed, but it returns a non-zero exit code due to its internal error. You can add echo statements inside your shell script to trace execution progress.

from serge.

akougblenou avatar akougblenou commented on August 30, 2024

The script could be not be executed, I did not thought of such a trivial thing!
Thanks for the help.

from serge.

akougblenou avatar akougblenou commented on August 30, 2024

Here is another question:
I had some translation in a json file to be used in i18next it looks like so:

{
  "title":"This is a simple showcase of what I18next can do",
  "title_text":"Texte",
  "plurals_intro":"It can pluralize words (and do nexting as well):",
  "plurals":"I got {{count}} cat.",
  "plurals_plural":"I got {{count}} cats.",
  "plurals_indefinite":"I got a cat",
  "plurals_plural_indefinite":"I got few cats",
  "plurals_indefinite_intro":"With i18next it is even possible to number thing undefinely",
  "units_intro":"I maybe able to talk about units:",
  "units":"e.g. I am 5ft3 and I drink at least 33.87oz of water per day",
  "currencies_intro":"And regarding currencies:",
  "currencies":"e.g. I would not buy a watch of 400$ but I wouldn't mind buying a car of 2000$",
  "currencies":{
    "intro": "e.g. I wouldn't buy a watch that costs",
    "price": " {{amount, currency}},",
    "otherprice": " but I could buy a car that costs {{amount, currency}}"
    },
  "dates": "Today is {{date, moment}}."
}

Using a i18next converter I convert it to po:

msgid ""
msgstr ""
"Project-Id-Version: i18next-conv\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"POT-Creation-Date: 2017-06-16T10:15:10.453Z\n"
"PO-Revision-Date: 2017-06-16T10:15:10.453Z\n"
"Language: en\n"

msgid "title"
msgstr "Ceci est une démonstration basique de ce que i18next peut faire"

msgid "plurals"
msgid_plural "plurals"
msgstr[0] " J'ai {{count}} chat."
msgstr[1] "J'ai des chats."

msgid "units"
msgstr "e.g. Je fais 1m73 et je bois au moins 1 litre d'eau par jour"

msgid "currencies##intro"
msgstr "e.g. Je n'acheterai pas une montre à"

msgid "currencies##price"
msgstr " {{amount, currency}},"

msgid "currencies##otherprice"
msgstr " mais je pourrais acheter une voiture à {{amount, currency}}"

msgid "dates"
msgstr "Nous sommes le {{date, DD/MM/YYY}} aujourd'hui"

msgctxt "intro"
msgid "plurals"
msgstr "Il gère la pluralization (et gère des architectures complexes):"

msgctxt "intro"
msgid "plurals_indefinite"
msgstr "Avec i18next on peut même dénombrer de façon indéfini."

msgctxt "intro"
msgid "units"
msgstr "Il peut peut-être gérer les unités de mesures:"

msgctxt "intro"
msgid "currencies"
msgstr "Et pour la monnaie:"

msgctxt "indefinite"
msgid "plurals"
msgstr "J'ai un chats."

Now when I used the localize command on serge I get the following

msgid ""
msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: en\n"
"Generated-By: Serge 1.2\n"

#. File: common.po
#. ID: 9e27fd754028b81fd9958d4be674d250
#. File: common.po
#. ID: 9e27fd754028b81fd9958d4be674d250
#: File: en/common.po
#: ID: 9e27fd754028b81fd9958d4be674d250
msgid "title"
msgstr "title"

#. File: common.po
#. ID: 866bbebaf91f794216ab509e468fc7d4
#. File: common.po
#. ID: 866bbebaf91f794216ab509e468fc7d4
#: File: en/common.po
#: ID: 866bbebaf91f794216ab509e468fc7d4
msgid "plurals"
msgid_plural "plurals"
msgstr[0] "plurals"
msgstr[1] "plurals"

#. File: common.po
#. ID: dd6fa65a2a127e7511d0ac1d0c63b0a6
#. File: common.po
#. ID: dd6fa65a2a127e7511d0ac1d0c63b0a6
#: File: en/common.po
#: ID: dd6fa65a2a127e7511d0ac1d0c63b0a6
msgid "units"
msgstr "units"

#. File: common.po
#. ID: 559dce9fcff70b925043d8157a71d3ca
#. File: common.po
#. ID: 559dce9fcff70b925043d8157a71d3ca
#: File: en/common.po
#: ID: 559dce9fcff70b925043d8157a71d3ca
msgid "currencies##intro"
msgstr "currencies##intro"

#. File: common.po
#. ID: 9ef0f48d03d0c6bff99127be29d2e7d9
#. File: common.po
#. ID: 9ef0f48d03d0c6bff99127be29d2e7d9
#: File: en/common.po
#: ID: 9ef0f48d03d0c6bff99127be29d2e7d9
msgid "currencies##price"
msgstr "currencies##price"

#. File: common.po
#. ID: e1dd75fae22d6d47ab107bc61ef3abaa
#. File: common.po
#. ID: e1dd75fae22d6d47ab107bc61ef3abaa
#: File: en/common.po
#: ID: e1dd75fae22d6d47ab107bc61ef3abaa
msgid "currencies##otherprice"
msgstr "currencies##otherprice"

#. File: common.po
#. ID: 47c2166be6467ed79d7e1447d86d3a8b
#. File: common.po
#. ID: 47c2166be6467ed79d7e1447d86d3a8b
#: File: en/common.po
#: ID: 47c2166be6467ed79d7e1447d86d3a8b
msgid "dates"
msgstr "dates"

#. File: common.po
#. ID: ef5aafd76a1696d59287fbd7ae684cc4
#. File: common.po
#. ID: ef5aafd76a1696d59287fbd7ae684cc4
#: File: en/common.po
#: ID: ef5aafd76a1696d59287fbd7ae684cc4
msgctxt "intro"
msgid "plurals"
msgstr "plurals"

#. File: common.po
#. ID: 09092d478968b8325599349a7ae224d0
#. File: common.po
#. ID: 09092d478968b8325599349a7ae224d0
#: File: en/common.po
#: ID: 09092d478968b8325599349a7ae224d0
msgctxt "intro"
msgid "plurals_indefinite"
msgstr "plurals_indefinite"

#. File: common.po
#. ID: 5f4a51f0c9c2b5da0a22cb1cb84f4934
#. File: common.po
#. ID: 5f4a51f0c9c2b5da0a22cb1cb84f4934
#: File: en/common.po
#: ID: 5f4a51f0c9c2b5da0a22cb1cb84f4934
msgctxt "intro"
msgid "units"
msgstr "units"

#. File: common.po
#. ID: e50921b5c8cc38ca24e9d4541f21ed26
#. File: common.po
#. ID: e50921b5c8cc38ca24e9d4541f21ed26
#: File: en/common.po
#: ID: e50921b5c8cc38ca24e9d4541f21ed26
msgctxt "intro"
msgid "currencies"
msgstr "currencies"

#. File: common.po
#. ID: 8bd0aa9d337b3cb0942715a52a716d93
#. File: common.po
#. ID: 8bd0aa9d337b3cb0942715a52a716d93
#: File: en/common.po
#: ID: 8bd0aa9d337b3cb0942715a52a716d93
msgctxt "indefinite"
msgid "plurals"
msgstr "plurals"

Shouldn't the msgstr be empty in the files serge as created ?
I don't understand why do I get this strange output

from serge.

iafan avatar iafan commented on August 30, 2024

You don't need any converters. Serge can work with JSON format directly (see parse_json), and after localization it will create JSON files as well.

The fact that you see English strings in .po files is because you currently use .po as a source format for localization, and whenever Serge generates localized copies, it renders original source strings where translations are not present, to make sure the localized resource can be used as is without adding any fallback support to display source strings. You could override this behavior by using the leave_untranslated_blank option, but again, you don't need to do any conversion in the first place, and once you start working with JSON directly, Serge will generate translation .po files, and these .po files will have blank msgstr fields when there's no translation.

from serge.

akougblenou avatar akougblenou commented on August 30, 2024

This is an excerpt of one of my .po file:

msgid ""
msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: es\n"
"Generated-By: Serge 1.2\n"

#. /currencies/intro
#: File: common.json
#: ID: d3a589d6f81bc53b483b247884cc2ccc
msgid "e.g. I wouldn't buy a watch that costs"
msgstr "e.g. I wouldn't buy a watch that costs"

#. /currencies/otherprice
#: File: common.json
#: ID: 29ac476fe7cbeb2697579c970b583e53
msgid "but I could buy a car that costs {{amount, currency}}"
msgstr " but I could buy a car that costs {{amount, currency}}"

#. /currencies/price
#: File: common.json
#: ID: 74d3dc5160eaef8146955241c227787d
msgid "{{amount, currency}},"
msgstr " {{amount, currency}},"

#. /currencies_intro
#: File: common.json
#: ID: 750b2e7401ae54da39d02062f7cce4ff
msgid "And regarding currencies:"
msgstr "And regarding currencies:"

ad you can see the msgid and msgstr are exactly alike I was thinking that the msgid should match the json key of the translation and the translation to be blank as I have set the flag as per your recommendation, but it does no seem so...

from serge.

iafan avatar iafan commented on August 30, 2024

Did you switch to the parse_json parser? Could you please share your current config file?

from serge.

akougblenou avatar akougblenou commented on August 30, 2024

Gladly here:

sync
{
    ts
    {
        plugin                  pootle

        data
        {
            manage_py_path      prepare.sh
            project_id          test
        }
    }

    vcs
    {
        plugin                   git

        data
        {
            # (STRING) Absolute path to local folder where local
            # checkout will be stored.
            local_path           pootle

            # (STRING) Path to a single remote repository
            # to sync with local `data_dir` folder
            remote_path         some_git_ssh_link

            # (BOOLEAN) [OPTIONAL] should the newly generated
            # files be added to the remote repository automatically?
            # (YES or NO, defaults to NO)
            add_unversioned      NO

            # (STRING) [OPTIONAL] Commit message
            # Default: 'Automatic commit of updated project files'
            commit_message       Automatic commit of updated project files

            # (STRING) public committer name
            name                 Test i18n

            # (STRING) commiter's email address
            email                [email protected]
        }
    }


    # other sync parameters
    # ...
}

jobs
{
    # job 1
    {
        id                      pootle.translate.i18n
        name                    TESTPOCV4
        optimizations               YES
        active                      YES
        source_language         en
        destination_languages   es fr
        debug                   YES
        db_source               DBI:SQLite:dbname=./translate.db3
        db_namespace            test
        source_dir              /path_to_the_pootle_dir_simlinking_to_my_project/test/en
        source_process_subdirs      YES
        #source_match            \.po$
        source_match            \.json$

        #parser
        #{
            # (STRING) Parser class name.
            # See Serge/Engine/Plugin/parse_*.pm files
        #    plugin                  parse_pot
        #}

        parser
        {
            plugin               parse_json
        }

        leave_untranslated_blank    YES
        normalize_strings           YES

        ts_file_path                /path_to_the_pootle_dir_simlinking_to_my_project/test/%LOCALE%/%NAME%.po
        reuse_translations          NO
        output_encoding             UTF-8
        output_lang_files           YES
        output_default_lang_file    NO
        output_file_path            /path_to_the_pootle_dir_simlinking_to_my_project/test/%LOCALE%/%FILE%


        # other job parameters
        # ...
    }

    # other jobs
    # ...
}

from serge.

iafan avatar iafan commented on August 30, 2024

I think that the reason why you still see msgstr populated with English strings is because your translation database is already contaminated with incorrect "translations" from your previous experiments. If you are just experimenting with Serge and don't have any real translations in the database, you can try deleting translate.db3 and .po files and running serge localize again.


I made a local test (and I recommend recreating it in a separate folder to make sure you're actually looking at the new files generated from a blank database, and not some previously incorrectly generated files):

Go to some empty folder and create two files (including the subfolders):

src/en/test.json

{
  "title":"This is a simple showcase of what I18next can do",
  "title_text":"Texte",
  "plurals_intro":"It can pluralize words (and do nexting as well):",
  "plurals":"I got {{count}} cat.",
  "plurals_plural":"I got {{count}} cats.",
  "plurals_indefinite":"I got a cat",
  "plurals_plural_indefinite":"I got few cats",
  "plurals_indefinite_intro":"With i18next it is even possible to number thing undefinely",
  "units_intro":"I maybe able to talk about units:",
  "units":"e.g. I am 5ft3 and I drink at least 33.87oz of water per day",
  "currencies_intro":"And regarding currencies:",
  "currencies":"e.g. I would not buy a watch of 400$ but I wouldn't mind buying a car of 2000$",
  "currencies":{
    "intro": "e.g. I wouldn't buy a watch that costs",
    "price": " {{amount, currency}},",
    "otherprice": " but I could buy a car that costs {{amount, currency}}"
    },
  "dates": "Today is {{date, moment}}."
}

localize.serge

jobs
{
    {
        id                      pootle.translate.i18n
        name                    TESTPOCV4
        source_language         en
        destination_languages   es fr
        db_source               DBI:SQLite:dbname=./translate.db3
        db_namespace            test
        source_dir              ./src/en
        source_process_subdirs  YES
        output_file_path        ./src/%LOCALE%/%FILE%
        source_match            \.json$
        normalize_strings       YES

        ts_file_path            ./po/%LOCALE%/%NAME%.po

        parser
        {
            plugin              parse_json
        }
    }
}

(this is basically your job without parameters that are already set by default and with modified paths to work against local test files).

Now in the folder with localize.serge run:

serge localize

After that you can look at the generated /po folder and subfolders — it will contain .po files that all have a blank msgstr. The /src folder will have /es and /fr subfolders created, and generated JSON files will all have the original (English) strings in them.

Now you can edit one of the .po files (provide your translation) and run serge localize again. Your translation will be propagated into the JSON file.

from serge.

akougblenou avatar akougblenou commented on August 30, 2024

@iafan thanks for the answer and sorry for the delayed answer.
I will try out these this week and get back to you on the outcome !!

from serge.

akougblenou avatar akougblenou commented on August 30, 2024

This ticket is now obsolete, I manage to find what I was looking for, through the help of @iafan on Gitter, so I am going to close this issue.

from serge.

Related Issues (20)

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.