6.1.9 • Published 6 days ago

@meniga/translations v6.1.9

Weekly downloads
100
License
MIT
Repository
-
Last release
6 days ago

@meniga/translations

This package handles localization using the i18next module

Translations


There are two ways to use localization for translated content:

  1. import { Translate } from '@meniga/translations'

<Translate name="someNamespace:someKeyName" />

  1. import { tfx } from '@meniga/translations'

{ tfx('someNamespace:someKeyName') }

Date formats


This package also has a utility method to fetch the predefined date formats that are found in the dateformatting.json localization file.

Example:

import { getDateFormat } from '@meniga/translations'

const _configDateFormat = getDateFormat('dateFormat')

where 'dateFormat' is the name of the translated key in the dateformatting.json file.

Configuration


The i18n configuration options can be found here: https://www.i18next.com/overview/configuration-options

Create a i18n.js config file in your app to configure your i18next setup. Configuration options for i18next should go in the "init" property.

Example config:

module.exports = {
	init: {
		debug: false,
		fallbackLng: 'en',
		ns: ['app', 'dateformatting', 'numberFormatting'],
		defaultNS: 'app',
		fallbackNS: 'app',
		appendNamespaceToMissingKey: false,
		returnEmptyString: false,
	},
	useBackend: true,
	loadPath: '/public/localization-{{lng}}/{{ns}}.json',
	expirationTime: 7*24*60*60*1000,
	cacheVersions: {
		en: 'v1.0',
		is: 'v1.0',
	},
	cultures: [
		{ label: 'English', value: 'en-GB'}
	]
}
  • init is for config options supported by i18next, such as defining the default namespaces and languages to load

  • useBackends defines whether or not to use a backend (with caching) for translations or to load them in memory. If backend is used, language packs can be added/edited during runtime, and don't require a new build. You can define what the path to the language packs is, and when the cache should be expired.

  • loadPath defines the location of the files when using backend

  • expirationTime defines the time in milliseconds when the backend cache should be automatically expired

  • cacheVersions is an object you can use to specify a version for each culture, in order to control the caching. If a version is bumped the cache will automatically be expired.

  • cultures a list of supported cultures in Bank42 that will appear in the Change Culture dropdown component

6.1.9

6 days ago

6.1.8

24 days ago

6.1.3-alpha.0

1 month ago

6.1.1-alpha.0

1 month ago

6.1.4-alpha.0

1 month ago

6.1.6

1 month ago

6.1.5

1 month ago

6.1.2-alpha.0

1 month ago

6.1.7

1 month ago

6.1.0

1 month ago

6.0.37-alpha.0

1 month ago

6.0.38-alpha.0

1 month ago

6.0.34-alpha.0

1 month ago

6.0.36-alpha.0

1 month ago

6.0.35-alpha.0

1 month ago

6.0.32-alpha.0

1 month ago

6.0.30-alpha.0

1 month ago

6.0.33-alpha.0

1 month ago

6.0.29-alpha.0

1 month ago

6.0.31-alpha.0

1 month ago

6.0.28-alpha.0

1 month ago

6.0.25-alpha.0

2 months ago

6.0.27-alpha.0

2 months ago

6.0.24-alpha.0

2 months ago

6.0.26-alpha.0

2 months ago

6.0.23-alpha.0

2 months ago

6.0.21-alpha.0

4 months ago

6.0.22-alpha.0

4 months ago

6.0.20-alpha.0

4 months ago

6.0.17-alpha.0

4 months ago

6.0.19-alpha.0

4 months ago

6.0.13-alpha.0

4 months ago

6.0.15-alpha.0

4 months ago

6.0.16-alpha.0

4 months ago

6.0.18-alpha.0

4 months ago

6.0.12

4 months ago

6.0.2-alpha.0

6 months ago

6.0.11-alpha.0

6 months ago

5.0.0-alpha.14864

8 months ago

5.0.0-alpha.14902

6 months ago

1.0.0-alpha.0

6 months ago

6.0.7-alpha.0

6 months ago

6.0.9-alpha.0

6 months ago

6.0.1-alpha.0

6 months ago

6.0.12-alpha.0

6 months ago

6.0.0

6 months ago

6.0.4

6 months ago

6.0.4-alpha.0

6 months ago

4.11.1-alpha.120

3 years ago

5.0.0-alpha.48

3 years ago

5.0.0-alpha.47

3 years ago

5.0.0-alpha.17

3 years ago

5.0.0-alpha.18

3 years ago

5.0.0-alpha.0

3 years ago

4.9.1-alpha.185

3 years ago

4.11.0

3 years ago

4.9.1-alpha.176

3 years ago

4.9.1-alpha.169

3 years ago

4.9.1-alpha.134

3 years ago

4.9.0

4 years ago

4.8.1-alpha.233

4 years ago

4.8.1-alpha.189

4 years ago

4.8.1-alpha.182

4 years ago

4.8.1-alpha.148

4 years ago

4.8.1-alpha.46

4 years ago

4.6.1-alpha.217

4 years ago

4.6.1-alpha.175

4 years ago

4.6.0

5 years ago

4.2.1-alpha.1

5 years ago

4.2.0

5 years ago

4.1.1-alpha.175

5 years ago

4.1.1-alpha.174

5 years ago

4.1.1-alpha.115

5 years ago

4.1.1-alpha.114

5 years ago

4.1.1-alpha.113

5 years ago

4.1.1-alpha.74

5 years ago

4.1.0

5 years ago

4.0.4-alpha.229

5 years ago

4.0.4-alpha.192

5 years ago

4.0.4-alpha.191

5 years ago