Skip to content

Instantly share code, notes, and snippets.

@dixonsiu
Created August 21, 2017 08:01
Show Gist options
  • Save dixonsiu/78a8e5ee28a2447be76d9e73a166d16c to your computer and use it in GitHub Desktop.
Save dixonsiu/78a8e5ee28a2447be76d9e73a166d16c to your computer and use it in GitHub Desktop.
Proper way to translate sentence with variable

Modifying element's attribute does not work.

    is.displaySearchResult = function(count) {
        $('#searchResult')
            .attr("data-i18n", "candidateFilter:searchResult")
            .attr("data-i18n-options", '{ "count": ' + count + ' }')
            .localize();
    };

Passing the data-i18n-options as options of localize.

    is.displaySearchResultNew = function(count) {
        $('#searchResult')
            .attr("data-i18n", "candidateFilter:searchResult")
            .localize({ count: count});
    };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment