Skip to content
Snippets Groups Projects
Verified Commit 9c7d4c1b authored by Volker Schukai's avatar Volker Schukai :alien:
Browse files

feat: Improve formatting and clarity in translation handling

Summary of changes
- Updated comment formatting in `formatter.mjs` for consistency.
- Reformatted imports in `translations.mjs` for better readability.
- Enhanced constructor logic in `Translations` class to handle locale input more flexibly.

- `formatter.mjs`:
  - Corrected a minor typo in JSDoc comments to improve clarity—changed "value is not a object" to "value is not an object".

- `translations.mjs`:
  - Reformatted import statements for consistency, aligning them neatly, which makes it easier to read and manage.
  - Simplified locale handling logic in `Translations` constructor by adding a fallback option that retrieves translations if the provided locale is not an instance of Locale or a string.
parent a3df3ca0
No related branches found
No related tags found
No related merge requests found
...@@ -41,7 +41,7 @@ class Formatter extends TextFormatter { ...@@ -41,7 +41,7 @@ class Formatter extends TextFormatter {
* @param {object} object * @param {object} object
* @param {Translations} translation * @param {Translations} translation
* @param {object} [options] * @param {object} [options]
* @throws {TypeError} value is not a object * @throws {TypeError} value is not an object
*/ */
constructor(object, translation, options) { constructor(object, translation, options) {
super(object, options); super(object, options);
......
...@@ -47,8 +47,10 @@ class Translations extends Base { ...@@ -47,8 +47,10 @@ class Translations extends Base {
if (locale instanceof Locale) { if (locale instanceof Locale) {
this.locale = locale; this.locale = locale;
} else { } else if (isString(locale)) {
this.locale = parseLocale(validateString(locale)); this.locale = parseLocale(validateString(locale));
} else {
this.locale = getDocumentTranslations()
} }
this.storage = new Map(); this.storage = new Map();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment