-
Notifications
You must be signed in to change notification settings - Fork 45
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
i18n: Add full i18n support #84
Conversation
c464ead
to
148d879
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than storing the vendor js files in our repo, load it from somewhere, like cdnjs, jsdelivr or unpkg.
This will avoid the need to ignore those files in our linter, and it's the best that we can do before implementing a build system that takes care of npm/js package in the browser.
.coafile
Outdated
@@ -1,6 +1,6 @@ | |||
[all] | |||
files = **.js, **.json, **.css, **.yml, **.html, .eslintrc | |||
ignore = node_modules/**, out/**, package-lock.json | |||
ignore = node_modules/**, out/**, package-lock.json, static/js/lib/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't do this please, we want those files to be linted
static/js/i18n/hi.json
Outdated
"last-updated": "आखरी अपडेट", | ||
"order-info": "प्रत्येक संगठन (और उनके GitHub खाते, यदि लागू हो) के लिए प्रमुख प्रतिभागी क्रमशः सूचीबद्ध होते हैं", | ||
"tasks-completed": "पूरा कार्य", | ||
"footer-text": "Google Code-in और इसके लोगो Google Inc. के ट्रेडमार्क हैं", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indent problem.
static/js/i18n/id.json
Outdated
"tasks-completed": "Tugas selesai", | ||
"footer-text": "Google Code-in dan logonya adalah merek dagang terdaftar dari Google Inc.", | ||
"orgs-no-listed": "Organisasi tanpa pemimpin yang terdaftar", | ||
"passed": "$1% passed, approximately $2 before task claiming ends", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if it isnt translated, it should be omitted, so that we can build checks for percentage translated, and tools to create translations.
does jquery.i18n
not support fallback to English for missing messages?
If it doesnt, please dont include languages which you dont know your translation is 100% accurate and complete. We can use http://hosted.weblate.org/ to manage the collection of translations and ensure they are complete before the file is available for the i18n layer.
static/js/i18n/hi.json
Outdated
@@ -0,0 +1,21 @@ | |||
{ | |||
"page-title": "Google Code-in 2017 वर्तमान नेता", | |||
"last-updated": "आखरी अपडेट", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where did you get this translation from?
Is that translation MIT licensed per #6?
If not, please remove, and we'll acquire the translation again using a method that complies with the intended license of this repo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO we should remove all translation for now and only keep en
or 2.
@@ -9,7 +9,7 @@ bears = SpaceConsistencyBear | |||
default_actions = *: ApplyPatchAction | |||
|
|||
[all.linelength] | |||
ignore += **.html | |||
ignore += **.html, static/js/i18n/**.json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ugh? Why is this?
They should all be unicode, and should all be nicely structured JSON.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JSON doesn't have linebreaks and the translations for some strings are too long for the linelength limit.
templates/main.html
Outdated
/> | ||
</a> | ||
{{/github}} | ||
{{#mailing_list}} | ||
<a href="{{mailing_list}}"> | ||
<img src="images/mail.png" class="chat" alt="Join their mailing list" /> | ||
<img src="images/mail.png" class="chat" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why removing all the alt
?
jquery.i18n
doesnt support them?
English only alt
is better than no alt
..?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
may also be related to the #78 merge
templates/main.html
Outdated
<head> | ||
<meta charset="utf-8"> | ||
<title>GCI Leaders</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like it is doing something unrelated to the issue you are solving..?
please correct me if I am wrong about that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like it was related to https://github.com/coala/gci-leaders/pull/78/files#diff-c8935f416a66e3b982a42dccd8206926L6
templates/main.html
Outdated
@@ -1,22 +1,33 @@ | |||
<!DOCTYPE html> | |||
<html lang="en"> | |||
<html> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lang="mul".
If not, it should still be lang=en
, because it is only with JavaScript enabled that it is multilingual, and the JavaScript should update the lang attribute as required.
unack 911e838 |
Sorry those were conflicts with rebasing from master as |
Can you add a languange switcher? Maybe using |
static/js/global.js
Outdated
@@ -0,0 +1,24 @@ | |||
var browser_locale = window.navigator.language.split('-')[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
camelCase please
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops too accustomed to python hehe
static/js/global.js
Outdated
updateTranslation(browser_locale) | ||
$('#lang-select').val(browser_locale) | ||
$('#lang-select').on('change', function() { | ||
updateTranslation(this.value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice if the user's preference is saved (preferably in localStorage), so that the user doesn't need to change it on every visit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also why is this not in the other file? (language_switcher)
templates/main.html
Outdated
<script src="js/app.js"></script> | ||
<script> | ||
$(window).on('load', function() { | ||
$.getScript('js/app.js') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw you were using defer
before, why change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
defer
was not working properly. I implemented this workaround to make sure that the translation file finished importing before applying the translations
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
translation file finished importing
Then it's not $(window).on('load')
, there must be another event from jquery.i18n
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It needs to because the text to translate (the HTML) needs to load as well so $(window).on('load')
is the correct way.
static/css/main.css
Outdated
|
||
.chooser { | ||
margin-top: 0.5em; | ||
display: flex; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you need flex
console.log('i18n:' + localex + ' locale loaded') | ||
$('body').i18n() | ||
$('html').attr('lang', localex) | ||
$.getScript('js/app.js') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
^ You have done it here.
}) | ||
} | ||
|
||
$(window).on('load', function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$(window).on('load')
is here ^
static/js/global.js
Outdated
var nav = window.navigator | ||
browserLocale = | ||
nav.language.split('-')[0] || nav.language || nav.userLanguage || '' | ||
localStorage.setItem('lang', browserLocale) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only store if the user has specifically selected a language.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
This adds i18n support for the app, being rendered in client-side so that translations can be loaded dynamically. Implemented language fallbacks for non-existing translations, plurals and dynamic placeholders for strings. Fixes coala#38
ack 2899de9 |
This adds i18n support for the app, being
rendered in client-side so that translations
can be loaded dynamically. Implemented language
fallbacks for non-existing translations, plurals
and dynamic placeholders for strings.
Fixes #38