prosopopee icon indicating copy to clipboard operation
prosopopee copied to clipboard

internationalization

Open julienmalik opened this issue 8 years ago • 8 comments

I need to make prosopopee multilingual. Probably it is not so much work and modifications, so i'd like to implement it.

Opening this issue in the hope to get feedback first (so that it has a chance to get merged upstream in the future).

My initial thoughts:

Any title/subtitle/text could have :

  • one default version, as it is today
  • a number of optional translations like :
title: Hello
  fr : Salut
  es: Ola

The list of translations might need to be referenced from the main settings. Then for each page we render the different flavors :

  • index.html
  • index.fr.html
  • index.es.html

and in all headers, we put a small widget with flags to switch between languages (ideas welcome for that, i'm far from fluent in html/css/js).

julienmalik avatar Feb 15 '16 14:02 julienmalik

Also, loading of the proper translated flavor of the site depending on user's settings would be awesome, but this is probably impossible with a static website. is it really ?

julienmalik avatar Feb 15 '16 14:02 julienmalik

See https://www.flag-sprites.com/ for free flags with css code ready

julienmalik avatar Feb 15 '16 14:02 julienmalik

with a small javascript snippet it should be possible to redirect to the user's language specific version of the page (more or less like simone does for yunohost doc ?)

julienmalik avatar Feb 15 '16 14:02 julienmalik

See https://github.com/yunohost/yunohost-admin/blob/unstable/src%2Fjs%2Fyunohost%2Fmain.js#L111-L119

redirect in js with : document.location.href = "https://tonporn.com"

julienmalik avatar Feb 15 '16 14:02 julienmalik

Jinja has a gettext extension : http://jinja.pocoo.org/docs/dev/extensions/#i18n-extension This could probably help a lot, and decouple quite well localization functionnalities from the core of prosopopee.

I made an attempt with stuff like :

title:
  fr: Salut
  es: Ola

but I fear this will become complex to handle all the different text attributes of individual sections which all have a different data model (e.g. full-picture and text).

julienmalik avatar Feb 15 '16 22:02 julienmalik

Regarding flags: I've been taugh that using flag is apparently bad for i18n and that language name or short name should be used instead.

Psycojoker avatar Feb 16 '16 10:02 Psycojoker

An experiment i'm relatively happy with : https://gist.github.com/julienmalik/e6544ad26e82bae4381c

julienmalik avatar Feb 16 '16 14:02 julienmalik

beginning of a solution here : https://github.com/julienmalik/prosopopee/tree/internationalization it generates index.$lang.html for all langs if you put e.g. :

multilingual: 
  - fr
  - es

in the root settings.yaml

to be multilingual the gallery .yaml then needs to be like :

title:
    fr: Salut
    es: Ola

but the monolingual case is still supported as before. when generating a multilingual version, if a string is not translated (title: Hello) then it is used for all languages.

multi langages are supported only for title, subtitle and text keys.

julienmalik avatar Feb 17 '16 11:02 julienmalik