Open kxrom opened 5 years ago
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:
/* 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);
}
}
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:
lighterhtml
Thanks for your input!
Below some few liquid.us translations: