Skip to content

Commit

Permalink
Re apply translations if tap language was changed (#4470)
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigok authored Sep 27, 2016
1 parent 57a2705 commit cc536a0
Showing 1 changed file with 20 additions and 13 deletions.
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();
});
});

0 comments on commit cc536a0

Please sign in to comment.