lehitoskin / ivy

Ivy, the Taggable Image Viewer
GNU General Public License v3.0
16 stars 3 forks source link

Translations #64

Open lehitoskin opened 7 years ago

lehitoskin commented 7 years ago

It may at some point become desirable to create translations for many of the different menu items and such, including the help-string text. Here's how I envision this could go:

  1. Create a giant hash that is dynamically loaded on-run (through read or some such) 1a. One file per language might be best 1b. Place them inside the ivy directory
  2. Determine the language from configuration file? Perhaps from environment variables? (Need to look up language environment variables for the three platforms)
  3. hash-ref for when there's things we want to translate

Some concerns:

  1. What to do when there are no translation files available? Built-in default English translation hash? Fail with an error?
  2. Will this make startup times increase too much? If necessary, look into setting the language as a compile-time thing, perhaps reading the environment variable (or some other setting) so we can speed things up.
IonoclastBrigham commented 7 years ago

Standard behavior for this kind of thing:

  1. fall back on english if there's no strings file for the user's locale, or if a particular string is missing from the correct file (i.e. not translated yet)
    1. you may also want to let them override the system default with a setting string or environment variable, e.g. their computer is set to Mandarin/Simplified which say we didn't support (yet), but they know French better than English for whatever reason, so they set the language to fr_FR or whatever to make things a little easier on themselves
  2. load the strings dynamically, possibly at program startup; for an app this size the added overhead should be basically inconsequential, but allows the user to change their system default and restart the app in a new language

I'm betting there's at least one standard/official localization library for racket already, and probably a handful of popular ones that are good quality and well-maintained by the community. On the face of it, this is a pretty simple problem that you could hack together without much effort, but it gets trickier when you have to do things like take grammatical number into account when building format strings, gender, person, case, etc. So it's probably better to use something that already exists if you can.

lehitoskin commented 7 years ago

There is the string-constants module, but it only effects DrRacket's GUI elements, so the best we can do is copy and adapt its structure.

IonoclastBrigham commented 7 years ago

I fully expect there to be something comparable on github, or in the repo at https://pkgs.racket-lang.org. Just need to poke around a bit.

The more different the language is from english, the more involved localization is, if you're displaying anything other than fully static pre-translated text. If you wanted to include something like "Found %d matching files", some languages might have different pluralization for two files versus 3+ files.

Just something to think about.