@lion/localize
Advanced tools
Comparing version 0.21.3 to 0.22.0
# Change Log | ||
## 0.22.0 | ||
### Minor Changes | ||
- fad9d8e5: add option to show the key as a fallback when a locale is missing a translation | ||
### Patch Changes | ||
- 30805edf: Replace deprecated node folder exports with wildcard exports for docs | ||
- Updated dependencies [30805edf] | ||
- Updated dependencies [495cb0c5] | ||
- Updated dependencies [2b583ee7] | ||
- Updated dependencies [83011918] | ||
- @lion/core@0.20.0 | ||
- singleton-manager@1.4.3 | ||
## 0.21.3 | ||
@@ -4,0 +20,0 @@ |
@@ -12,3 +12,3 @@ # Systems >> Localize >> Overview ||10 | ||
Further examples and a more in depth description can be found at the [Features Page](https://github.com/ing-bank/lion/blob/c59dda0c93f15f94b5f6287f8df6ac1ba29ff9e5/docs/docs/systems/localize/features.md). | ||
Further examples and a more in depth description can be found at the [Features Page](https://github.com/ing-bank/lion/blob/745c809ce06b2dce0ee4e47749ce2b5ca23bd769/docs/docs/systems/localize/features.md). | ||
@@ -19,5 +19,5 @@ ## Content | ||
| ---------------------------------------- | --------------------------------------------- | | ||
| [Translate Text](https://github.com/ing-bank/lion/blob/c59dda0c93f15f94b5f6287f8df6ac1ba29ff9e5/docs/docs/systems/localize/text.md) | Load and translate text in multiple languages | | ||
| [Format Numbers](https://github.com/ing-bank/lion/blob/c59dda0c93f15f94b5f6287f8df6ac1ba29ff9e5/docs/docs/systems/localize/numbers.md) | Format numbers in multiple languages | | ||
| [Format Dates](https://github.com/ing-bank/lion/blob/c59dda0c93f15f94b5f6287f8df6ac1ba29ff9e5/docs/docs/systems/localize/dates.md) | Format dates in multiple languages | | ||
| [Translate Text](https://github.com/ing-bank/lion/blob/745c809ce06b2dce0ee4e47749ce2b5ca23bd769/docs/docs/systems/localize/text.md) | Load and translate text in multiple languages | | ||
| [Format Numbers](https://github.com/ing-bank/lion/blob/745c809ce06b2dce0ee4e47749ce2b5ca23bd769/docs/docs/systems/localize/numbers.md) | Format numbers in multiple languages | | ||
| [Format Dates](https://github.com/ing-bank/lion/blob/745c809ce06b2dce0ee4e47749ce2b5ca23bd769/docs/docs/systems/localize/dates.md) | Format dates in multiple languages | | ||
@@ -24,0 +24,0 @@ ## Installation |
{ | ||
"name": "@lion/localize", | ||
"version": "0.21.3", | ||
"version": "0.22.0", | ||
"description": "The localization system helps to manage localization data split into locales and automate its loading", | ||
@@ -37,4 +37,4 @@ "license": "MIT", | ||
"@bundled-es-modules/message-format": "6.0.4", | ||
"@lion/core": "0.19.0", | ||
"singleton-manager": "1.4.2" | ||
"@lion/core": "0.20.0", | ||
"singleton-manager": "1.4.3" | ||
}, | ||
@@ -52,4 +52,4 @@ "keywords": [ | ||
"./test-helpers": "./test-helpers/index.js", | ||
"./docs/": "./docs/" | ||
"./docs/*": "./docs/*" | ||
} | ||
} |
@@ -12,3 +12,3 @@ # Systems >> Localize >> Overview ||10 | ||
Further examples and a more in depth description can be found at the [Features Page](https://github.com/ing-bank/lion/blob/c59dda0c93f15f94b5f6287f8df6ac1ba29ff9e5/docs/docs/systems/localize/features.md). | ||
Further examples and a more in depth description can be found at the [Features Page](https://github.com/ing-bank/lion/blob/745c809ce06b2dce0ee4e47749ce2b5ca23bd769/docs/docs/systems/localize/features.md). | ||
@@ -19,5 +19,5 @@ ## Content | ||
| ---------------------------------------- | --------------------------------------------- | | ||
| [Translate Text](https://github.com/ing-bank/lion/blob/c59dda0c93f15f94b5f6287f8df6ac1ba29ff9e5/docs/docs/systems/localize/text.md) | Load and translate text in multiple languages | | ||
| [Format Numbers](https://github.com/ing-bank/lion/blob/c59dda0c93f15f94b5f6287f8df6ac1ba29ff9e5/docs/docs/systems/localize/numbers.md) | Format numbers in multiple languages | | ||
| [Format Dates](https://github.com/ing-bank/lion/blob/c59dda0c93f15f94b5f6287f8df6ac1ba29ff9e5/docs/docs/systems/localize/dates.md) | Format dates in multiple languages | | ||
| [Translate Text](https://github.com/ing-bank/lion/blob/745c809ce06b2dce0ee4e47749ce2b5ca23bd769/docs/docs/systems/localize/text.md) | Load and translate text in multiple languages | | ||
| [Format Numbers](https://github.com/ing-bank/lion/blob/745c809ce06b2dce0ee4e47749ce2b5ca23bd769/docs/docs/systems/localize/numbers.md) | Format numbers in multiple languages | | ||
| [Format Dates](https://github.com/ing-bank/lion/blob/745c809ce06b2dce0ee4e47749ce2b5ca23bd769/docs/docs/systems/localize/dates.md) | Format dates in multiple languages | | ||
@@ -24,0 +24,0 @@ ## Installation |
@@ -10,5 +10,6 @@ /** | ||
export class LocalizeManager { | ||
constructor({ autoLoadOnLocaleChange, fallbackLocale }?: { | ||
constructor({ autoLoadOnLocaleChange, fallbackLocale, showKeyAsFallback, }?: { | ||
autoLoadOnLocaleChange?: boolean | undefined; | ||
fallbackLocale?: string | undefined; | ||
showKeyAsFallback?: boolean | undefined; | ||
}); | ||
@@ -21,2 +22,4 @@ /** @private */ | ||
protected _fallbackLocale: string; | ||
/** @protected */ | ||
protected _showKeyAsFallback: boolean; | ||
/** | ||
@@ -23,0 +26,0 @@ * @type {Object.<string, Object.<string, Object>>} |
@@ -17,3 +17,7 @@ // @ts-expect-error [external]: no types for this package | ||
// eslint-disable-line no-unused-vars | ||
constructor({ autoLoadOnLocaleChange = false, fallbackLocale = '' } = {}) { | ||
constructor({ | ||
autoLoadOnLocaleChange = false, | ||
fallbackLocale = '', | ||
showKeyAsFallback = false, | ||
} = {}) { | ||
/** @private */ | ||
@@ -25,2 +29,4 @@ this.__delegationTarget = document.createDocumentFragment(); | ||
this._fallbackLocale = fallbackLocale; | ||
/** @protected */ | ||
this._showKeyAsFallback = showKeyAsFallback; | ||
@@ -579,3 +585,3 @@ /** | ||
return String(result || ''); | ||
return String(result || (this._showKeyAsFallback ? key : '')); | ||
} | ||
@@ -582,0 +588,0 @@ |
@@ -680,2 +680,16 @@ import { expect, oneEvent, aTimeout } from '@open-wc/testing'; | ||
}); | ||
describe('show key as fallback', () => { | ||
it('shows the key as a fallback when a translation cannot be found', () => { | ||
manager = new LocalizeManager({ showKeyAsFallback: true }); | ||
manager.addData('en-GB', 'my-ns', { greeting: 'Hello!' }); | ||
expect(manager.msg('my-ns:unknownKey')).to.equal('my-ns:unknownKey'); | ||
}); | ||
it('shows nothing when a translation cannot be found by default', () => { | ||
manager = new LocalizeManager(); | ||
manager.addData('en-GB', 'my-ns', { greeting: 'Hello!' }); | ||
expect(manager.msg('my-ns:unknownKey')).to.equal(''); | ||
}); | ||
}); | ||
}); | ||
@@ -682,0 +696,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
271131
5543
+ Added@lion/core@0.20.0(transitive)
+ Addedsingleton-manager@1.4.3(transitive)
- Removed@lion/core@0.19.0(transitive)
- Removedsingleton-manager@1.4.2(transitive)
Updated@lion/core@0.20.0
Updatedsingleton-manager@1.4.3