Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How should we i18n liquid.us? [question] #120

Open
kxrom opened this issue Apr 18, 2019 · 1 comment
Open

How should we i18n liquid.us? [question] #120

kxrom opened this issue Apr 18, 2019 · 1 comment

Comments

@kxrom
Copy link
Contributor

kxrom commented Apr 18, 2019

Hello,

How should we translate your software, do you know what solution you'd like?

Or maybe you know what solutions you wouldn't like? Do you have any idea?

There are a lots of ways to do it:

Thanks for your input!

Below some few liquid.us translations:

// liquid.us
// French translations

{
    "Search Bills or People" : "Recherche de projets de loi ou de personnes",
    "Legislation" : "Législation",
    "Join" : "Rejoindre",
    "Login" : "Se connecter",
    "Your Proxies" : "Vos procurations",
    "You" : "Vous",
    "Verify your identity" : "Vérifiez votre identité",
    "Profile" : "Profil",
    "Proposed Legislation" : "Vos propositions",
    "Settings" : "Paramètres",
    "Sign out" : "Se déconnecter",
    "Upcoming for vote" : "Prochains scrutins",
    "Recently introduced" : "Nouveaux projets de loi",
    "Introduced on Liquid" : "Projets de l'assemblée liquide",
    "Bills recently introduced." : "Les projets de loi récemment introduits.",
    "Bills upcoming for a vote in the legislature." : "Les projets de loi seront soumis au vote de l'Assemblée législative.",
    "Bills introduced on Liquid" : "Projets introduits sur l'assemblée liquide.",
    "Hide voted" : "Cacher les propositions que vous avez déjà votées",
    "Next" : "Suivant",
    "Help" : "Aide",
    "%s makes democracy smarter and more accountable." : "%s rend la démocratie plus intelligente et plus responsable.",
    "Add Proxy" : "Ajout de procurations",
    "Search for new proxies among public %s profiles:" : "Recherche de nouveaux délégués parmi les profils publics :",
    "search by Name" : "Recherche de profils",
    "Invite by Email" : "Invitation par courriel",
    "Invite by Twitter" : "Invitation par Twitter",
    "Proxy to someone not on Liquid via email:" : "Donnez procuration à quelqu'un qui n'a pas encore de profil par e-mail :",
    "Proxy to someone not on Liquid by adding their Twitter username:" :
      "Donnez procuration à quelqu'un en ajoutant son nom d'utilisateur Twitter :",
    "You don't have any proxies yet." :
      "Vous n'avez pas encore de procurations.",
    "%s lets you pick anyone to represent you. You can change at anytime, and you can always override them and vote directly on bills." :
      "%s vous permet de choisir n'importe qui pour vous représenter. Vous pouvez les modifier à tout moment, et vous pouvez toujours voter directement sur les projets de loi.",
    "For any item that you don't vote on, one of your proxies get an additional vote. This ensures that your values are still represented, even when you don't have the time to look into all the issues." :
      "Pour toute proposition sur laquelle vous ne votez pas, l'une de vos procurations obtient un vote supplémentaire. Cela garantit que votre opinion soit toujours représentée, même si vous n'avez pas le temps d'examiner toutes les questions.",
}
@kxrom
Copy link
Contributor Author

kxrom commented Apr 20, 2019

Here's a workaround below with a nodejs script using replace-in-file to translate in files. See related #122 and commit.

With this workaround plus customizing some few views files we can probably localize the UI:

Capture1


Capture2


Capture3


/* Translate script */
const dict = require('./liquid.us.fr.json')                            // Translations
const files = ['../liquid.us/views/*.js', '../liquid.us/models/*.js']  // Project files
const replace = require('replace-in-file')                             // Replace-in-file library

var options = {
  files: files,
  from: [],
  to: []
}

// Replace strings within ><, "", `` and '' with the json translations.
function from(entry){
  return [  new RegExp(">" + escapeRegExp(entry) + "<", 'g'),
            new RegExp("'" + escapeRegExp(entry) + "'", 'g'),
            new RegExp("`" + escapeRegExp(entry) + "`", 'g'),
            new RegExp('"' + escapeRegExp(entry) + '"', 'g') ]
}
function to(entry){
  return [  ">" + entry + "<",
            "'" + entry + "'",
            "`" + entry + "`",
            '"' + entry + '"' ]
}
function escapeRegExp(string) { return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); }

for (var entry in dict) {
  options = {
    files: options.files,
    from: from(entry),
    to: to(dict[entry])
  }
  try {
    const changes = replace.sync(options);
    console.log('Replaced: ' + entry + ' -> ' + dict[entry])
    console.log('==> Modified files:', changes.join(', '))
  }
  catch (error) {
    console.error('Error occurred:', error);
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant