1.2.1 • Published 6 years ago

@fooxly/translation v1.2.1

Weekly downloads
-
License
ISC
Repository
-
Last release
6 years ago

Fooxly translation

This is a simple custom translation module.

Usage

setup

import { Language, Translation, string } from "@fooxly/translation";

const languages = {
  'en-US': require('./translations/en-US.json'),
  'nl-NL': require('./translations/nl-NL.json')
}

Language.setup(languages, {
  default: 'en-US',
  useBrowserLanguage: false
});

update language

To update the current language run:

myUpdateMethod() {
  if(Language.set('nl-NL')) {
    // a valid language code was given
  }
  this.forceUpdate();
}

add language elements

Language items can be created by importing the Translation component:

<Translation id='foo.bar'/>

Language items can also be given as props:

string('foo.bar')

The ID is the key from the language file(defined before). The language file will look look like this:

{
  "foo": {
    "bar": "Bar"
  }
}
1.2.1

6 years ago

1.2.0

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago