Skip to content

Commit

Permalink
Possible fix for #388
Browse files Browse the repository at this point in the history
  • Loading branch information
MichMich committed Aug 2, 2016
1 parent 3d3c4ba commit 18ae08d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion js/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ var Module = Class.extend({

// If a translation file is set, load it and then also load the fallback translation file.
// Otherwise only load the fallback translation file.
if (translationFile !== undefined) {
if (translationFile !== undefined && translationFile !== translationsFallbackFile) {
Translator.load(self, translationFile, false, function() {
Translator.load(self, translationsFallbackFile, true, callback);
});
Expand Down

4 comments on commit 18ae08d

@MrHarcombe
Copy link

@MrHarcombe MrHarcombe commented on 18ae08d Aug 3, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might be over-thinking it, but wouldn't it be better to also have an else if to catch the case where you want to load the translationFile and not the (duplicate) translationsFallbackFile?

ie

            if (translationFile !== undefined && translationFile !== translationsFallbackFile) {
                Translator.load(self, translationFile, false, function() {
                    Translator.load(self, translationsFallbackFile, true, callback);
                });
            } else if (translationFile !== undefined) {
                Translator.load(self, translationFile, false, callback);
            } else {
                Translator.load(self, translationsFallbackFile, true, callback);
            }

This seems to work better for me, as otherwise it loads the translations as the fallback file if the two files are the same (which seems to cause problems for the MMM-Voice-Recognition module that I'm using.

@MrHarcombe
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact, why don't I pop this up as PR...

@MichMich
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My recent change would fix the issue of loading twice the same file. The fallback file always needs to be loaded, even if the desired file is loaded as well, because the desired translation file does not always include every translation. In that case it can fall back to a translation of the fallback file.

@MrHarcombe
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, right, sorry.

I guess the change is more properly needed in the module, then, to handle the case that the information it's looking for isn't in the translation file?

Please sign in to comment.