LeeVD / plasma-applet-net-bandwidth-monitor

Network bandwidth monitor for plasma using dbus
GNU General Public License v3.0
25 stars 4 forks source link

[Feature Request] i18n support #6

Closed CatEricka closed 1 year ago

CatEricka commented 1 year ago

Excellent project, and I'd love to add Chinese translations, but don't know how to do that and what the best practice is...

LeeVD commented 1 year ago

This is definitely something I've had in the back of my mind to include. The code I built upon had reference to i18n, i just need to work out how to get that to work. Its all new to me :) Ta.

CatEricka commented 1 year ago

After testing, at least the current workflow can be used normally, maybe some issues need to be solved manually. To run this need installed gettext package, depends on your distribution.

Extract new text: cd plasma-applet-net-bandwidth-monitor/package/translate and execute bash ./merge, This checks all i18n() function called and merges them into template.pot and *.po

Update all *.po, then build *.mo file and copy to package/contents/locale: cd plasma-applet-net-bandwidth-monitor/package/translate by execute bash ./build.

The run-translate-test script is just a memo, it is not clear how to configure the locale variables for now

CatEricka commented 1 year ago

New translation available: #12 ; no proofreading yet

If you can, please follow git best practices: uploading after deleting all files will increase the downstream workload, because then I have to delete all code rewrite all the changes :smiley_cat:

LeeVD commented 1 year ago

I'm new to git for app management but I'm aware i need to utilise it better! Translations is next on my list. I've given you more translation work with the new 'info/tooltip' sections :D Will the translations work in a text field using html code? I'll need your help to make sure it works correctly.

Thanks CatErika!

CatEricka commented 1 year ago

Will the translations work in a text field using html code?

Using the way of concatenating strings, yes, html code works fine.

CatEricka commented 1 year ago

https://github.com/CatEricka/plasma-applet-net-bandwidth-monitor/blob/1901972f2531ce6afd31f73dd05a73ac874a04de/package/contents/ui/config/ConfigGeneral.qml#L946-L963

CatEricka commented 1 year ago

I had to modify the original text because GNU gettext did not recognize the original text format. Now only the parts that need to be translated will be translated.

Note that the indentation of some text looks wrong, this is intentional.

GNU gettext can't handle String.raw syntax, and I don't know the details of how QML and gettext work together, so I can only use this way to fix it.

LeeVD commented 1 year ago

@CatEricka v0.3.2 should now contain your translations. I tested it in plasmaviewer with the language switch and it looks ok to me. Can you please test and let me know if everything is accurate?

CatEricka commented 1 year ago

@LeeVD

File package/translate/template.pot is needed to make it easier for other users to submit translations, and it is also part of the script generation.

Also, if you can, please merge my code by merging the pull request, you can also edit my pull request; if edit the main branch instead of merging the pull request, I have to cross compare all commits to keep track of the update of the main branch. :)

Other than that, everything should work fine. Thanks for your work.

LeeVD commented 1 year ago

I missed the second merge once the .po file was created. That is now done and the script recreated the template.pot file for future translation use.