Skip to content

codeliveru/translate-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Include script to HTML

<script src="translate.js"></script>

Declare translations

var messages = {
    en_US = {
        success: {
            comment: {
                add: 'Your comment has been added successfully',
                remove: 'Your comment has been removed',
                edit: 'Your comment has been updated'
            },
            feedback: {
                send: 'Your feedback successfully send to administrator',
                receive: 'New response for your feedback has been received'
            }
        }
    }
};

Setup the default language

var settings = {
    lang: 'en_US'
};

Translate

With default language:

var translated = tr('success:comment:add');

With custom language:

var translated = tr('success:comment:edit', 'ru_RU');

About

Javascript localization tools

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published