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

Re apply translations if tap language was changed #4470

Merged
merged 1 commit into from
Sep 27, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 20 additions & 13 deletions packages/rocketchat-lib/client/CustomTranslations.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
Meteor.startup(function() {
Meteor.autorun(function() {
let CustomTranslations = RocketChat.settings.get('Custom_Translations');
if (typeof CustomTranslations === 'string' && CustomTranslations.trim() !== '') {
try {
CustomTranslations = JSON.parse(CustomTranslations);
RocketChat.applyCustomTranslations = function applyCustomTranslations() {
let CustomTranslations = RocketChat.settings.get('Custom_Translations');
if (typeof CustomTranslations === 'string' && CustomTranslations.trim() !== '') {
try {
CustomTranslations = JSON.parse(CustomTranslations);

for (const lang in CustomTranslations) {
if (CustomTranslations.hasOwnProperty(lang)) {
const translations = CustomTranslations[lang];
TAPi18next.addResourceBundle(lang, 'project', translations);
}
for (const lang in CustomTranslations) {
if (CustomTranslations.hasOwnProperty(lang)) {
const translations = CustomTranslations[lang];
TAPi18next.addResourceBundle(lang, 'project', translations);
}
} catch (e) {
console.error('Invalid setting Custom_Translations', e);
}
TAPi18n._language_changed_tracker.changed();
} catch (e) {
console.error('Invalid setting Custom_Translations', e);
}
}
};

Meteor.startup(function() {
Meteor.autorun(function() {
// Re apply translations if tap language was changed
Session.get(TAPi18n._loaded_lang_session_key);
RocketChat.applyCustomTranslations();
});
});