dragos-efy / efy

User Customizable CSS / JS framework. Private, modular & convergent apps
https://efy.ooo
GNU Affero General Public License v3.0
63 stars 1 forks source link

Translation #6

Closed DarkCat09 closed 1 year ago

DarkCat09 commented 1 year ago

From Readme:

translate it into multiple languages statically (contact me if you know how)

Static translation can be done with json files like in deadlyjack/Acode.

I think, you should create a module named "efy-lang" or "efy-localization" and load&parse needed JSON from efy/lang/ directory.
Then use json keys in code instead of hardcoded strings.
Here is a pseudocode:

// javascript
const lang = 'en-us'
const content = get_file(`${langPath}/${lang}.json`)
const strings = JSON.parse(content)
set_button_text(strings.button_text)

// en-us.json
{
  "button_text": "I'm a button!",
  ...
}

// ru-ru.json
{
  "button_text": "Я - кнопка!",
  ...
}

The language (en-us, ru-ru, de-de, pt-br) can be set in EFY UI settings or/and automatically detected from navigator.language (for old browsers: navigator.userLanguage).

Also, I can help you with translating to Russian.

dragos-efy commented 1 year ago

pretty cool. I had something similar in mind, but your approach is probably better I think. I'll test it out in the coming days and let you know how it goes! Feel free to join the matrix room as well if you wanna discuss specific stuff. Would love help with Russian translation for sure!

dragos-efy commented 1 year ago

I found a solution, you can see 2 languages now if you go to efy sidebar > efy language. The translations are located inside the efy/lang/ folder in the repo in case you're curious. I'll integrate them with weblate for easier contributions from people like you, soon I think, so if you're still interested in helping with Russian, you're welcome to.

It won't be automated cuz I use a different format compared to the standard, since json for example can't be fetched on the file:/// protocol, but I'll let you know when I open up the integration, probably in the next 3-4 weeks. From your end all you have to do is just translate strings, I'll do all the conversion from my end once I get your strings.

dragos-efy commented 1 year ago

you can translate it here now: https://translate.codeberg.org/projects/efy/efy/