FreeDATA icon indicating copy to clipboard operation
FreeDATA copied to clipboard

Support for translations

Open DJ2LS opened this issue 4 years ago • 24 comments

Support for different languages in a separate file

DJ2LS avatar Aug 18 '21 19:08 DJ2LS

https://www.npmjs.com/package/i18n-js

DJ2LS avatar Mar 23 '23 09:03 DJ2LS

@Mashintime I'd like to work on this, soon. Are you interested, working on this?

DJ2LS avatar Aug 06 '23 17:08 DJ2LS

A previous project I've worked on implemented this, and personally feel it's a giant waste of time. Unless electron/node implement it in an easier way I personally have no interest. Feel this may be better for a 2nd beta or initial release as things are still pretty fluid development wise.

Mashintime avatar Aug 06 '23 20:08 Mashintime

I wouldn't call it a complete waste of time as long as many people in the world are not speaking English well enough. Nevertheless priority isn't too high at this - it's more because it's the oldest issue here. I'm wondering how's the complexity of i18n 🤔

DJ2LS avatar Aug 06 '23 22:08 DJ2LS

closing this one now as its not making sense enough. Better focusing on other topics

DJ2LS avatar Sep 30 '23 19:09 DJ2LS

I was looking if someone already no requested this...

Because my friend does not know English and asked why it is not translated. So maybe after 2 years you can reopen with low priority, but keep it at mind.

For me is English fine, but in Czech because of Russian invasion between 68-89 they forced learn Russian language and forbidden learn English, thus lot of 50+ years old HAMs does not know English more than "hello" or "thank you", which make complicated to overtalk them to use this application

petrkr avatar Feb 24 '25 20:02 petrkr

@petrkr thanks for your comment. The biggest problem is time. Would you be interested in working on this?

DJ2LS avatar Feb 25 '25 06:02 DJ2LS

If there will be already some i18n framework with po translation files, then rewritting text could be done step-by-step, not all texts and all translations at once.

My problem is I really do not know JavaScript nor vue. So if you can do in limited time some skeleton like 'here instedad text you will use _translate('id-texr', 'defaultvalue') then anyone can help by pull requests.

petrkr avatar Feb 25 '25 11:02 petrkr

So you are talking about an implementation example?

DJ2LS avatar Feb 25 '25 11:02 DJ2LS

Yes.

Include library, show example 1 string usage and en.po / en.mo

Rest can be done by others step-by-step.

I can also do that, but since I do not know vue framework it will be much more time for me just about learning framework itself and then implementation

petrkr avatar Feb 25 '25 11:02 petrkr

Okay, I think I can do this. I will reopen this issue, but I really need your help then :-)

DJ2LS avatar Feb 25 '25 11:02 DJ2LS

I did some research today to see if this is something I could try to start playing around with if I get someone to help.

Using localisation the translations are in different JSON files where english is default/fallback.

Also using Pythons built-in "gettext" can be used but then I think this has to be compiled into .mo files.

Anyhow both methods make it relatively easy for other users to help by pull requests.

The JSON method once adopted requires less work/maintenance. The "proper" way using i.e "gettext" requires the compilation of the .mo files.

Both the server and the GUI need this and JSON/"gettext" is both supported for javascript.

On Tue, Feb 25, 2025 at 12:03 PM Petr Kracík @.***> wrote:

If there will be already some i18n framework with po translation files, then rewritting text could be done step-by-step, not all texts and all translations at once.

My problem is I really do not know JavaScript nor vue. So if you can do in limited time some skeleton like 'here instedad text you will use _translate('id-texr', 'defaultvalue') then anyone can help by pull requests.

— Reply to this email directly, view it on GitHub https://github.com/DJ2LS/FreeDATA/issues/60#issuecomment-2681584951, or unsubscribe https://github.com/notifications/unsubscribe-auth/AASRNKUHN6WS5O22G4YCPAT2RREXRAVCNFSM6AAAAABXY65FRCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMOBRGU4DIOJVGE . You are receiving this because you are subscribed to this thread.Message ID: @.***> [image: petrkr]petrkr left a comment (DJ2LS/FreeDATA#60) https://github.com/DJ2LS/FreeDATA/issues/60#issuecomment-2681584951

If there will be already some i18n framework with po translation files, then rewritting text could be done step-by-step, not all texts and all translations at once.

My problem is I really do not know JavaScript nor vue. So if you can do in limited time some skeleton like 'here instedad text you will use _translate('id-texr', 'defaultvalue') then anyone can help by pull requests.

— Reply to this email directly, view it on GitHub https://github.com/DJ2LS/FreeDATA/issues/60#issuecomment-2681584951, or unsubscribe https://github.com/notifications/unsubscribe-auth/AASRNKUHN6WS5O22G4YCPAT2RREXRAVCNFSM6AAAAABXY65FRCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMOBRGU4DIOJVGE . You are receiving this because you are subscribed to this thread.Message ID: @.***>

-- Kai Günter Brandt Tlf: 40003512

Android apper: https://play.google.com/store/search?q=la3qma&c=apps&hl=no

Scannernytt App og LAHAM app for iphone/ipad: https://itunes.apple.com/no/developer/kai-gunter-brandt/id1159009854?mt=8

PCBWay https://pcbway.com/g/7a79gf

LA3QMA avatar Feb 25 '25 11:02 LA3QMA

I think we should separate this work - GUI and Server. While the server can stay for now in English, it might make more sense for the GUI.

DJ2LS avatar Feb 25 '25 11:02 DJ2LS

the branch "ls-i18n" contains a first working version. Have a look in gui settings how to do this. At least you have to do the following things:

  • Create a new language file with <iso>_<name>.json like en_English.json
  • create new variable files inside templates like {{ $t('settings_enable') }}
  • create variable inside language.

Notes:

  • Language files will be detected automatically.
  • Let's start with English settings first. Please think about a good naming. like <categorie>_<setting or whatever>
  • As soon as we have all variables created in English, we can continue with the specific language files, as the variable names are static.
  • Language files are stored in "locales" folder

DJ2LS avatar Feb 25 '25 13:02 DJ2LS

Do not develop wheel again, use .po and .mo with i18n

Because there are lot of already made software aimed for translations and also we can put to some opensource community.

If you will do it is some own format, noone else can edit it and it will be lot of pain to keep format.

Server I think does not need translations.

Poedit for local

https://weblate.org/en/ for cooperation

petrkr avatar Feb 25 '25 13:02 petrkr

As already partially discussed on discord, there seems to be i18next which might has support for po files - maybe just as a plugin. But I try to avoid using plugins which often tend to be outdated. Some JSON to po files converter seem ti be available as well

DJ2LS avatar Feb 25 '25 16:02 DJ2LS

So question is - can we use i18next or another i18 package for doing this easily out of the box

DJ2LS avatar Feb 25 '25 16:02 DJ2LS

Use import in js and have the translation in a json i18 should work with less work and out of the box

tir. 25. feb. 2025, 17:38 skrev DJ2LS @.***>:

So question is - can we use i18next or another i18 package for doing this easily out of the box

— Reply to this email directly, view it on GitHub https://github.com/DJ2LS/FreeDATA/issues/60#issuecomment-2682604137, or unsubscribe https://github.com/notifications/unsubscribe-auth/AASRNKSLST6UBVQZTB2CJI32RSMBRAVCNFSM6AAAAABXY65FRCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMOBSGYYDIMJTG4 . You are receiving this because you commented.Message ID: @.***> [image: DJ2LS]DJ2LS left a comment (DJ2LS/FreeDATA#60) https://github.com/DJ2LS/FreeDATA/issues/60#issuecomment-2682604137

So question is - can we use i18next or another i18 package for doing this easily out of the box

— Reply to this email directly, view it on GitHub https://github.com/DJ2LS/FreeDATA/issues/60#issuecomment-2682604137, or unsubscribe https://github.com/notifications/unsubscribe-auth/AASRNKSLST6UBVQZTB2CJI32RSMBRAVCNFSM6AAAAABXY65FRCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMOBSGYYDIMJTG4 . You are receiving this because you commented.Message ID: @.***>

LA3QMA avatar Feb 25 '25 17:02 LA3QMA

I littlebit investigate how Gettext works and it grab data for .pot files from source codes. Do not know how make it able to create .pot from Vue sources yet. But since it get strings from soruce codes it will be always up to date, because you will not forgot to add them by hand.

Now I working on secure element from tropicsquare, so I will take a look later if you both will not be faster

petrkr avatar Feb 25 '25 22:02 petrkr

doing some research, it seems, that some of the Gettext libraries are outdated. This library https://www.npmjs.com/package/gettext-parser is doing all we need it seems - converting Gettext to json. It seems, most i18n libraries are using json as their data format. But we could use such a tool for using po files, instead.

DJ2LS avatar Feb 26 '25 06:02 DJ2LS

I meanwhile also see the benefits of Gettext files. Thanks for mentioning, @petrkr

DJ2LS avatar Feb 26 '25 06:02 DJ2LS

Well, the po convertion really bloats code it seems. Most easy and simple is still using json.

DJ2LS avatar Feb 26 '25 07:02 DJ2LS

using the tool i18next-conv seems to help here. i18next-conv -l de -s de_Deutsch.json -t de_Deutsch.po converts to po file from json and back via i18next-conv -l de -s de_Deutsch.po -t de_Deutsch.json

DJ2LS avatar Feb 26 '25 08:02 DJ2LS

We should use nested keys:

{ "settings": { "audio": { "quality": "Audioqualität" } } }

{{ t('settings.audio.quality') }}

DJ2LS avatar Feb 28 '25 18:02 DJ2LS