Diego Búrigo Zacarão avatar Diego Búrigo Zacarão committed 3d02482

Also try to use code aliases for the auto-suggestion on Lotte

Comments (0)

Files changed (1)

transifex/templates/webtrans/js/google-translate.js

     source_lang = '{{ pofile.object.source_lang }}';
     file_lang = '{{ pofile.language_code }}';
     is_supported_lang = google.language.isTranslatable(file_lang);
+    // If the main language code is not supported, try to find one from the code aliases
+    if (!(is_supported_lang)){
+        // Get aliases
+        code_aliases = '{{ pofile.language.code_aliases }}';
+        if(code_aliases){
+            // Drop spaces in the beginning/end of the string and split it
+            list = code_aliases.replace(/^ /,'').replace(/ $/,'').split(' ');
+            for (i=0; i<list.length; i++){
+                is_supported_lang = google.language.isTranslatable(list[i]);
+                if (is_supported_lang){
+                    i=list.length;
+                }
+            }
+        }
+    }
     is_supported_source_lang = google.language.isTranslatable(source_lang);
     if (is_supported_lang && is_supported_source_lang) {
 	    $('a.suggest').click(function() {
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.