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

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

@skaldrom

Description

@skaldrom

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");
                        }
    }       

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions