Skip to content

Commit

Permalink
return key if not exists
Browse files Browse the repository at this point in the history
  • Loading branch information
KishiTheMechanic committed Nov 3, 2024
1 parent 3ba755a commit f743985
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@elsoul/fresh-i18n",
"version": "1.1.3",
"version": "1.2.0",
"description": "A simple and flexible internationalization (i18n) plugin for Deno's Fresh framework.",
"runtimes": ["deno", "browser"],
"exports": "./mod.ts",
Expand Down
6 changes: 3 additions & 3 deletions src/createTranslator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export function createTranslator(
* by traversing the nested structure of `translations`.
*
* @param key - The translation key in dot notation (e.g., 'common.title').
* @returns The translated string, or an empty string if the key is not found.
* @returns The translated string, or the key string if the key data is not found.
*/
const t = (key: string): string => {
const keys = key.split('.')
Expand All @@ -22,11 +22,11 @@ export function createTranslator(
if (typeof result === 'object' && result !== null && k in result) {
result = (result as Record<string, unknown>)[k]
} else {
return '' // Return empty string if key is not found
result = key
}
}

return typeof result === 'string' ? result : ''
return typeof result === 'string' ? result : key
}

return t
Expand Down

0 comments on commit f743985

Please sign in to comment.