AWS Amplify I18n module is a lightweight internationalization solution.
import { I18n } from 'aws-amplify';
// or
import { I18n } from '@aws-amplify/core';Sets the active language.
I18n.setLanguage('fr');In browser, Amplify detects browser language automatically. For mobile you may want to use other libraries to detect the language, and then set it using Amplify in your code. {: .callout .callout--info}
You can create your custom dictionary and set it as your vocabularies in your app. Dictionary is a JavaScript object that you can implement with different terms and languages.
const dict = {
'fr': {
'Sign In': "Se connecter",
'Sign Up': "S'inscrire"
},
'es': {
'Sign In': "Registrarse",
'Sign Up': "Regístrate"
}
};
I18n.putVocabularies(dict);Retrieves a phrase from the dictionary for the active language. If the phrase does not have an entry in dictionary, the original parameter value will be returned.
I18n.get('Sign In');For the complete API documentation for i18n module, visit our API Reference {: .callout .callout--info}