Skip to content
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

Fix plural rule issue with site interface translation #2345

Closed
wants to merge 1 commit into from
Closed

Fix plural rule issue with site interface translation #2345

wants to merge 1 commit into from

Conversation

hissy
Copy link
Contributor

@hissy hissy commented Apr 28, 2015

When I saved site translations to file, I got a Exception. The message is "Plural rule of merging text domain is not compatible with the current one". I can reproduce this issue when I have a Japanese section in my sitemap. I have also tested with two languages, English and Italian, but there is no problem.

Finally, I found this addition magically solves the issue, but I can't understand why.

@mlocati
Copy link
Contributor

mlocati commented Apr 28, 2015

I'm not able to reproduce that error. Could you describe every step to get it?

@hissy
Copy link
Contributor Author

hissy commented Apr 28, 2015

Thanks. Here is my screen record.

https://www.youtube.com/watch?v=46jxwesdc78

@mlocati
Copy link
Contributor

mlocati commented Apr 28, 2015

I did the exact same steps and everything is fine for me.

From what I can see, it seems that the system is trying to merge language files with different plural definitions.
For Japanese, the po files should contain the following header

"Plural-Forms: nplurals=1; plural=0;\n"

Could you check that both the /application/ja_JP/LC_MESSAGES/messages.po and /application/languages/site/ja_JP.po files contain it?

PS: if you have only the .mo files, you can decompile them with msgunfmt:

msgunfmt --output-file=messages.po messages.mo

@hissy
Copy link
Contributor Author

hissy commented Apr 28, 2015

Uploaded generated po/mo files.
ja_JP_decompile.po is a file which decompiled from ja_JP.mo with msgunfmt.

https://www.dropbox.com/sh/do65wh9rcze9usx/AADlzkh8d0qyM3337Gt95ytZa?dl=0

@mlocati
Copy link
Contributor

mlocati commented Apr 28, 2015

Those files were in the /application/languages/site folder?

@mlocati
Copy link
Contributor

mlocati commented Apr 28, 2015

If those files were in the /application/languages/site folder, it seems that they have been generated with a very old version of the composer libraries. Could you try to call composer install inside the web/concrete directory?

@hissy
Copy link
Contributor Author

hissy commented Apr 28, 2015

I've tried to run composer self-update and composer install but same result.
Have you core Japanese translation file in /application/languages/ja_JP/LC_MESSAGES/messages.po ?

@mlocati
Copy link
Contributor

mlocati commented Apr 28, 2015

Have you core Japanese translation file in /application/languages/ja_JP/LC_MESSAGES/messages.po ?

Yes. I downloaded it from Transifex and compiled to .mo. It starts with the correct headers:

msgid ""
msgstr ""
...
"Plural-Forms: nplurals=1; plural=0;\n"

And also the /application/languages/site/ja_JP.po starts with the correct headers:

msgid ""
msgstr ""
...
"Plural-Forms: nplurals=1; plural=0;\n"

@mlocati
Copy link
Contributor

mlocati commented Apr 28, 2015

I read your files more in depth, and I noticed that there's an error in the .po files:

msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2015-04-28T19:41:25+09:00\n"
"PO-Revision-Date: 2015-04-28T19:41:25+09:00\n"
"Language: ja_JP\n"
"Plural-Forms: nplurals=1; plural=0;\n"

#: application/blocks/custom_content_example/controller.php:21
msgid ""
msgstr ""

#: application/blocks/custom_content_example/controller.php:26
msgid "Custom Content Example"
msgstr ""

As you can see, we have two empty strings (msgid "").
The first (correct) is for the gettext headers, the second is totally wrong and I think that's what messes up your setup.
I'd be curious to see what you have at line 21 of the file application/blocks/custom_content_example/controller.php...

@hissy
Copy link
Contributor Author

hissy commented Apr 28, 2015

I'm so sorry. The error resolved with removing empty string in custom_content_example. I close this issue. Thank you for your kindness support and this great feature, @mlocati !

@hissy hissy closed this Apr 28, 2015
@mlocati
Copy link
Contributor

mlocati commented Apr 28, 2015

Thank you, Takuro 😉

BTW, I'd like to be sure that others won't incur in this same problem.
The line that made your installation crash was something like this?

echo t('');

@hissy
Copy link
Contributor Author

hissy commented Apr 28, 2015

Yes. I had echo t('');

@mlocati
Copy link
Contributor

mlocati commented Apr 28, 2015

php-gettext/Gettext#72 should fix such problems.

@mlocati mlocati mentioned this pull request Apr 28, 2015
@mlocati
Copy link
Contributor

mlocati commented Apr 28, 2015

#2349 fixes such problems (thanks to @oscarotero for his fast response 😉)

@hissy hissy deleted the hotfix/translate_interface branch April 29, 2015 01:15
@hissy
Copy link
Contributor Author

hissy commented Apr 29, 2015

Super fast! Thanks! 🎉

@hissy
Copy link
Contributor Author

hissy commented Oct 19, 2017

It happens again with 8.2.1

@mlocati
Copy link
Contributor

mlocati commented Oct 19, 2017

What's the version of gettext/gettext that you are using? (You should be able to see it in your composer.lock file)

@hissy
Copy link
Contributor Author

hissy commented Oct 19, 2017

Thank you

        {
            "name": "gettext/gettext",
            "version": "v3.5.9",
            "source": {
                "type": "git",
                "url": "https://github.com/oscarotero/Gettext.git",
                "reference": "5b1d69f5889513f7ed65060ad2a662ec3b0875c7"
            },
            "dist": {
                "type": "zip",
                "url": "https://api.github.com/repos/oscarotero/Gettext/zipball/5b1d69f5889513f7ed65060ad2a662ec3b0875c7",
                "reference": "5b1d69f5889513f7ed65060ad2a662ec3b0875c7",
                "shasum": ""
            },
            "require": {
                "gettext/languages": "2.*",
                "php": ">=5.3.0"
            },
            "require-dev": {
                "illuminate/view": "*",
                "twig/extensions": "*",
                "twig/twig": "*"
            },
            "suggest": {
                "illuminate/view": "Is necessary if you want to use the Blade extractor",
                "twig/extensions": "Is necessary if you want to use the Twig extractor",
                "twig/twig": "Is necessary if you want to use the Twig extractor"
            },
            "type": "library",
            "autoload": {
                "psr-4": {
                    "Gettext\\": "src"
                }
            },
            "notification-url": "https://packagist.org/downloads/",
            "license": [
                "MIT"
            ],
            "authors": [
                {
                    "name": "Oscar Otero",
                    "email": "oom@oscarotero.com",
                    "homepage": "http://oscarotero.com",
                    "role": "Developer"
                }
            ],
            "description": "PHP gettext manager",
            "homepage": "https://github.com/oscarotero/Gettext",
            "keywords": [
                "JS",
                "gettext",
                "i18n",
                "mo",
                "po",
                "translation"
            ],
            "time": "2016-02-19T15:18:12+00:00"
        },

@mlocati
Copy link
Contributor

mlocati commented Oct 19, 2017

Could you share the .po file that breaks the execution?

@hissy
Copy link
Contributor Author

hissy commented Oct 19, 2017

msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2017-10-19T13:49:53+09:00\n"
"PO-Revision-Date: 2017-10-19T13:49:53+09:00\n"
"Language: ja_JP\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

@mlocati
Copy link
Contributor

mlocati commented Oct 19, 2017

It's wrong: for Japanese there should be just 1 plural form...
How did you generate this file?

@hissy
Copy link
Contributor Author

hissy commented Oct 19, 2017

"Save to File" button on Translate Site Interface page. Thanks again...

@mlocati
Copy link
Contributor

mlocati commented Oct 19, 2017

Could you share the contents of the SiteLocales database table?

@biplobice
Copy link
Contributor

biplobice commented Oct 19, 2017

screen shot 2017-10-19 at 2 10 25 pm
SiteLocales.csv.zip

@mlocati
Copy link
Contributor

mlocati commented Oct 19, 2017

The 3 columns defining the plural rule is wrong:
Instead of
2, (n !=1), one@... other@...

You should have

1, 0, other@...

How did you add the Jaoanese locale to the website?

@biplobice
Copy link
Contributor

So far I know, installed by CLI with --site-locale=ja_JP.
@hissy did you do any update or changes?

@hissy
Copy link
Contributor Author

hissy commented Oct 19, 2017

@biplobice Nope, but we found the reason. Let's test clean installation and check the SiteLocales table.

@mlocati Thanks a lot!

@biplobice
Copy link
Contributor

biplobice commented Oct 19, 2017

So, the reason is-
The site was installed on version 8.1.0. But the SiteLocales hasn't update on version update to 8.2.1
I've checked with-

  • Concrete5 version update
  • Language pack update

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.

None yet

3 participants