Skip to content
This repository has been archived by the owner on Jun 28, 2019. It is now read-only.

i18n : Problen when no properties file for a language #7

Open
skaldrom opened this issue Sep 5, 2013 · 1 comment
Open

i18n : Problen when no properties file for a language #7

skaldrom opened this issue Sep 5, 2013 · 1 comment

Comments

@skaldrom
Copy link

skaldrom commented Sep 5, 2013

The i18n plugin can use the browsers preferred language for selecting a properties file and should fallback to the "Messages.properties" file.

Usually, you cannot provide properties files for all the possible languages, so some requests to files will fail, because they do not exist.

Problem: the event "i18n:complete" only gets triggered in the "success" part of the ajax request. If some files fail, it won't be triggered and the callback is never called, because it waits for this event.

Solution: Add an "error" function to the ajax request on line 256:

    $.ajax({
        url:        filename,
        async:      true,
        cache:      settings.cache,
        contentType:'text/plain;charset='+ settings.encoding,
        dataType:   'text',
        success:    function(data, status) {
                        parseData(data, settings.mode); 
                        _parsedFiles++;;
                        if(_parsedFiles>=_filesToLoad){
                           $(document).trigger("i18n:complete");
                        }
                    },
        error:    function(XMLHttpRequest, textStatus, errorThrown) { 
                        _parsedFiles++;;
                        if(_parsedFiles>=_filesToLoad){
                           $(document).trigger("i18n:complete");
                        }
    }       
@fpmweb
Copy link

fpmweb commented Nov 28, 2013

Great! thanks.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants