Skip to content

Updated zh_CN/music.mo#899

Merged
paulijar merged 8 commits into
owncloud:masterfrom
RuofengX:master
Sep 28, 2021
Merged

Updated zh_CN/music.mo#899
paulijar merged 8 commits into
owncloud:masterfrom
RuofengX:master

Conversation

@RuofengX
Copy link
Copy Markdown
Contributor

@RuofengX RuofengX commented Sep 26, 2021

Update zh_CN/music.mo from templete/music.mo, and add some translation. Try to solve issue #898

@RuofengX
Copy link
Copy Markdown
Contributor Author

RuofengX commented Sep 26, 2021

Some errors appear when trying to run make l10n-compile, I never used npm before. So the pr didn't countain translation.js file. I also need a new build because of this.
Here is the full log, if someone needed:

ubuntu@cloud:~/music/music/build$ sudo make l10n-compile
npm install --deps
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.1 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.1: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/watchpack-chokidar2/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

audited 908 packages in 5.608s

70 packages are looking for funding
  run `npm fund` for details

found 1 moderate severity vulnerability
  run `npm audit fix` to fix them, or `npm audit` for details
npm run l10n-compile

> music@1.3.3 l10n-compile /home/ubuntu/music/music/build
> angular-gettext-cli --compile --files ../l10n/**/music.po --dest ../js/app/l10n/translations.js --module Music

Finished compiling ../l10n/ach/music.po, read 1 files.
All files processed, stored in a file ../js/app/l10n/translations.js
cd ../l10n; ./l10n.pl music write
Can't locate Locale/PO.pm in @INC (you may need to install the Locale::PO module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.30.0 /usr/local/share/perl/5.30.0 /usr/lib/x86_64-linux-gnu/perl5/5.30 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.30 /usr/share/perl/5.30 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at ./l10n.pl line 3.
BEGIN failed--compilation aborted at ./l10n.pl line 3.
make: *** [Makefile:44: l10n-compile] Error 2

@paulijar
Copy link
Copy Markdown
Collaborator

Thanks! The error seems to happen after the translations.js is created. The script tries to create also localization files usable on the back-end, but this now fails because some Perl module is missing. But don't worry, I can do the technical steps.

I spotted one thing in the translations which would still need fixing. These strings:
image
have both singular form and plural form, although only the singular is shown in the list view of Poedit. But in the bottom of the screen, you should see both singular and plural forms and both translations should be supplied:
image

@RuofengX
Copy link
Copy Markdown
Contributor Author

Sorry, I missed some string somehow. It's been added now if nothing went wrong.

@paulijar
Copy link
Copy Markdown
Collaborator

Sorry, this still doesn't look quite right. Your second commit added the music.mo binary file but we don't need that for anything. We are only interested about the music.po file, and that didn't change at all in your second and third commits.

@RuofengX
Copy link
Copy Markdown
Contributor Author

Oh I confused with mo and po file. I will fix it later

@RuofengX
Copy link
Copy Markdown
Contributor Author

RuofengX commented Sep 27, 2021

OK, music.po file is up-to-date and music.mo is deleted. Maybe a rebase job is needed, actually it's my first time use git command line tool.

@paulijar
Copy link
Copy Markdown
Collaborator

Thanks, it's better but still doesn't address my original comment. If you look at the "Files changed" tab in github, it can be easily seen in the raw music.po file. For example, there is this block:

#: ../js/app/controllers/maincontroller.js:54
msgid "1 album"
msgid_plural "{{ count }} albums"
msgstr[0] "专辑"

There's supposed to be two translations, one for the case of only one album in the user's library and another one for the case when there are more than one. The latter translation should contain the placeholder {{ count }} which will get replaced with the numeral showing the actual count. In practice, 99+% of the cases will be such that there are more than 1 albums. This translation will be used as a tooltip, when the user is hoovering over the "Albums" links on the navigation pane.

Using Poedit, you should fill the translations of "1 album" on the tab "Singular" and the translation of "{{ count }} albums" on the tab "Plural".

@RuofengX
Copy link
Copy Markdown
Contributor Author

Actually mandarin doesn' t have a plural form. The word 专辑 means both album and albums. Also in mandarin, it is better add a unit before a object, let's say, 1张专辑, the word 张 means one or some pieces of album. And because of the dependence issue, I can't tell whether I need to add those unit words, so I would make more change after a build.
I also have a problem about the placeholder. I meet 2 kinds of placeholder, one is {{ count }}, Another is {{count}}, Which one is correct?

@RuofengX
Copy link
Copy Markdown
Contributor Author

Using Poedit, you should fill the translations of "1 album" on the tab "Singular" and the translation of "{{ count }} albums" on the tab "Plural".

I didn't notice the Singular and Plural tab, I just translate both 1 album and {{ count }} albums into 专辑, because they are the same thing in mandarin. Maybe I miss the place holder, I'll check it.

@RuofengX
Copy link
Copy Markdown
Contributor Author

Yes, the placeholder somehow missing, I will check it later.

Using Poedit, you should fill the translations of "1 album" on the tab "Singular" and the translation of "{{ count }} albums" on the tab "Plural".

@RuofengX
Copy link
Copy Markdown
Contributor Author

I think I find the problem. From Baidu ZhiDao
图片
The poedit program thinks that mandarin do not need a Plural form, because Single and Plural are same, so I can't see a Plural tab, instead, it only shows a tab called 一切, means any.
Also, {{ count }} albums is not the Plural form of 1 album that is the problem.
My advise is use two different string to store these different concept, or, I add the "Plural" form directly in plain file.

@paulijar
Copy link
Copy Markdown
Collaborator

Okay, if that is the case, then would it make sense to translate it as "{{ count }} 专辑" or something similar? And the {{ count }} there could then be number 1 or any greater number? I still need to check, if the application works technically correctly when only one translation is given like this.

@RuofengX
Copy link
Copy Markdown
Contributor Author

RuofengX commented Sep 27, 2021

I think that won' t work. If only one album is available, the placeholder won' t be replaced.
I want to use text editor to add the string directly. The question is whether the msgstr[0] "1张专辑"is for singular form and msgstr[1] "{{ count }}张专辑" is for plural form? If that' s correct I could add it directly using text editor. This could solve the problem temporarily with no change to upstream.

@RuofengX
Copy link
Copy Markdown
Contributor Author

RuofengX commented Sep 27, 2021

I updated the po file using things like msgstr[1] "{{ count }}张专辑".
And this solution do not need any change in sourse code.
All those problem is caused by poedit, BTW gettext plugin in vscode does not support strings like msgstr[0] whatever.

@paulijar
Copy link
Copy Markdown
Collaborator

I did now some testing, and the correct way seems to be to provide just one translation like "{{ count }}专辑". If we provide both singular and plural forms like in your latest commit, then the singular "1专辑" is always pulled by the translation library, regardless of the actual count.

In case you are interested, this is how we ask for the translated string in the code:

return gettextCatalog.getPlural(albumCount, '1 album', '{{ count }} albums', { count: albumCount });

Here, the gettextCatalog library automatically decides, which of the singular/plural translations to use, depending on the first argument albumCount. I guess that gettextCatalog also internally knows that there is supposed to be only one form for Chinese which is then used regardless of the count. I have read that gettextCatalog supports also languages using three different forms (1 item, 2 items, or 3+ items); e.g. Slovenian is such a language.

While testing, I also noticed one more thing to fix. In this translation, the parameter names and count do not match:

#: ../templates/partials/views/settingsview.php:156
msgid ""
"Array of allowed non-HLS radio streaming hosts. Default is ['http://*:*', "
"'https://*:*'], allowing streaming from any remote URL. The given URLs will "
"be added to the Content-Security-Policy header <a href=\"{{url}}\" target="
"\"_blank\">media-src</a>."
msgstr ""
"允许的非HLS电台流媒体主机列表。 默认值为['http://*:*', 'https://*:*'],允许来"
"自任何远程URL的流。 给定的URL将添加到标头Content-Security-Policy中<a href="
"\"{{connectSrcUrl}}\" target=\"_blank\">connect-src</a>。 此外,如果您指定任"
"何允许的来源,则来源<samp>data:</samp>和<samp>blob:</samp>也将添加到 CSP<a "
"href=\"{{mediaSrcUrl}}\" target=\"_blank\">media-src</a>。"

Also, that translation refers to the data: and blob: URLs which are not there in the original. They are part of the other quite similar string, but not this one.

Other than this, everything seemed to work technically correctly, and I saw no missing translations.

@paulijar
Copy link
Copy Markdown
Collaborator

As a mildly interesting technical detail, this line in music.po controls, which kind of singular/plural/etc. translations can be entered with Poedit:

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

In the Finnish translation file, the corresponding line is like this:

"Plural-Forms: nplurals=2; plural=(n != 1);\n"

And in the Slovenian file, it's like this:

"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);\n"

But none of these definitions are migrated to translations.js, so the gettext library must have corresponding/compatible definitions built-in and hard-coded per language.

@RuofengX
Copy link
Copy Markdown
Contributor Author

RuofengX commented Sep 27, 2021

Thanks for those careful test. I think I know how gettext works now. I'll update these in next commit.


Also, that translation refers to the data: and blob: URLs which are not there in the original. They are part of the other quite similar string, but not this one.

I made a mistake, thanks for notice!

@scrutinizer-notifier
Copy link
Copy Markdown

A new inspection was created.

@paulijar
Copy link
Copy Markdown
Collaborator

Thanks, looks correct now. I'll test this one more time in the evening, and then merge if I find no more issues.

@paulijar paulijar merged commit 5e20172 into owncloud:master Sep 28, 2021
@paulijar
Copy link
Copy Markdown
Collaborator

Everything worked great now, so I squashed and merged the commits. Thanks again for your contribution, it's much appreciated! The translations will be included in the next Music release v1.4.0 which I hope to be able to publish within a couple of weeks.

@paulijar
Copy link
Copy Markdown
Collaborator

The Music v1.4.0 with the Chinese translations is now released.

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.

3 participants