Commit Graph

21 Commits

Author SHA1 Message Date
Shubham Dhama b002ef26b7 i18n: Fix reference error for localstorage. 2018-05-30 23:28:21 +05:30
Tim Abbott 3f0a1e7c54 translations: Clean up indentation for initialization code. 2018-05-30 09:14:20 -07:00
Tim Abbott d9347dea3e i18n: Remove now-unused ensure_i18n function. 2018-05-30 09:13:48 -07:00
Shubham Dhama cff40c557b translations: Load translations from page_params.translation_data.
With this commit, we change how we deal with translation for strings.
Previously we used to fetch the translations data after loading which
created a lot of unpleasant race bugs.

So we changed this to use the `translation_data` sent in `page_params`
which is available at load time. The previous fetching can be useful if
we want to change the string to the changed language without reloading
the page but since we ask the user to reload the page after changing
the default language so fetching after loading isn't useful for us and
hence we can add resource only once.

Ultimately, we can remove the i18next plugins too.  We leave the logic
for clearing local storage, patched to fully clear it.

Fixes: #9087.
2018-05-30 08:57:27 -07:00
Umair Khan 7ad177abe6 i18n: Flag emojiset type name string for translation.
The other emojiset types are things like "Google", and "Twitter",
which don't need to be translated.  And the string is already tagged
for translation as a variable where it is used here:

  static/templates/settings/display-settings.handlebars#L87

Fixes #7970.
2018-02-22 05:36:03 -08:00
Tim Abbott bd5e7f8965 Revert "i18n: Only load active language."
This reverts commit f04981513b.

We're not sure, but we suspect that this made Zulip not show es for
folks using es_es as their locale.  Further testing is required.
2017-10-20 10:08:17 -07:00
Umair Khan f04981513b i18n: Only load active language.
Before this if we selected zh-hans then i18next would laod zh-hans, zh and
en. Now it will only load zh-hans.
2017-10-19 17:56:49 -07:00
Umair Khan 69fc227eb8 i18n: Create loadPath function.
This function returns the correct URL to retrieve zh-Hans from Django.

Fixes #6885
2017-10-19 17:56:49 -07:00
Umair Khan 326a6f6b4f i18next: Don't allow empty string as valid translation.
Previously we used to mark a key as unstranlated if its value was equal
to it in translations.json. This had an issue because it didn't allow
otherwise valid cases where key was equal to the value.

This commit solves the problem by disallowing an empty string as a valid
translation and then using the empty string as the value for all the
unstranslated keys.

Fixes #5261
2017-10-05 22:44:34 -07:00
Max Schaefer 4d0f304048 js: Fix two misphrased conditions. 2017-08-22 09:37:15 -07:00
Jack Zhang 10bef65f00 i18n: Import localstorage module into translations.
localstorage.supported() breaks on portico pages, where
the localstorage variable is not exposed globally.

This change is coupled with this commit:
94a1070979 (diff-a15e4886338acf8091c948c25f47caaa)
2017-08-10 10:21:53 -07:00
Brock Whittaker 3d4198c681 Replace `String.prototype.startsWith` with `indexOf`.
This replaces the `startsWith` string prototype method with `indexOf`
because no versions of Internet Explorer support this feature, and
it really is not difficult to just use `indexOf` instead and check
whether the starting index of the full string is 0.
2017-08-08 12:06:32 -07:00
Tim Abbott 94a1070979 i18n: Don't try to clear local storage caches if no local storage. 2017-07-28 12:18:33 -07:00
Tim Abbott 93418c6eb4 translations: Remove unnecessary cache clearing code.
Since the browser reloads when new server versions are deployed, the
other similar block already handles this issue.
2017-07-28 12:18:15 -07:00
Umair Khan 6536384e4b i18next: Remove older translation caches.
Any cache entry which doesn't belong to the current server_generation
is removed.

Fixes #5545.
2017-07-28 11:04:11 -07:00
Umair Khan fd9b7210ef i18next: Clear cache on restart event. 2017-07-28 11:04:11 -07:00
Tim Abbott cbd5223429 i18next: Disable i18n cache in development. 2017-07-13 21:37:56 -07:00
Tim Abbott 8c5cce7f2b i18next: Decrease cache expiration time to a couple days. 2017-07-13 21:34:35 -07:00
Brock Whittaker e3f1d025ae i18n: Garbage collect old translations from localStorage.
The old translation copies in localStorage were not being removed
when they were no longer needed, so we can free up the storage
by deleting them.

This was accidentally not merged months ago when originally
implemented, but it was written to fix #4443 and in fact does so.
2017-07-13 21:33:49 -07:00
digi0ps f228700ef2 webpack: Migrate translations.js to use ES2015 syntax. 2017-06-22 16:43:33 -04:00
Mehanig 3f5d0e69fb Build and handle jsfiles using webpack instead of django-pipeline.
Also renames bundle.js to translations.js.
2017-05-24 18:38:03 -07:00