glossary-page-template icon indicating copy to clipboard operation
glossary-page-template copied to clipboard

Need multiple language support

Open Faridbabayev001 opened this issue 2 years ago • 2 comments

Hello. First of all, it's a great system. Mainly the UI part. I would like to thank everyone who contributed.

The system currently supports one language. All static words are in English. Can you add multiple language support to the system? There is no language option in the menu. It is enough to have a json file for each language inside the code (for example, en.json). I can rename the json file before building and rebuild that way. I want to use it as a dictionary. I want all the content of the site to be in the same language. I tried changing the static words from within the code. But this is very difficult. I think it would be great if you could add multiple language support to the system.

P.S Sorry for my English

Faridbabayev001 avatar Oct 23 '23 20:10 Faridbabayev001

Hi -- thank you for suggesting this!

I like the idea and will try to spend time on this after I manage to get the next "major" version released (I'm currently working to add support for tags along with other improvements). It might take a little while.

hilverd avatar Oct 24 '23 20:10 hilverd

I think I have made some progress with this.

There is now a folder called Internationalisation. Each file in this folder contains all the UI text for a specific language. The files are named according to ISO 639-2 codes. They contain Elm code rather than JSON because that seemed much easier, but the code should not be very complicated to work with.

The file Internationalisation.elm determines which language is used. By default it uses English:

import Internationalisation.Eng as I18n

For example, to switch to Dutch, you can change that line to

import Internationalisation.Nld as I18n

and then run a build:

pnpm run build
./bin/prepare-release
cd release
tar -zvxf glossary-page-template-*.tar.gz

This is not very sophisticated (and I'm assuming more work is needed to support e.g. languages with a right-to-left script) -- but maybe it is good enough for your use case?

If it is good enough then a pull request with a translation would be very welcome :smile:. I could then make other languages available in releases.

hilverd avatar Dec 08 '23 15:12 hilverd