@nextcloud/l10n
Advanced tools
Comparing version 3.0.1 to 3.1.0
# Changelog | ||
All notable changes to this project will be documented in this file. | ||
## 3.1.0 - 2024-05-07 | ||
### Added | ||
* Allow setting `escape` option per parameter replacing.\ | ||
For more security this should be used instead of disabling paramter escaping, | ||
see [pull request #756](https://github.com/nextcloud-libraries/nextcloud-l10n/pull/756) | ||
```js | ||
// Example | ||
t( | ||
'my-app', | ||
'{a}{userInput}{a_end}', | ||
{ | ||
a: { | ||
value: '<a>', | ||
escape: false, | ||
}, | ||
userInput: somePossiblyInsecureValue, // This will be escaped | ||
a_end: { | ||
value: '</a>', | ||
escape: false, | ||
} | ||
}, | ||
) | ||
``` | ||
## 3.0.1 - 2024-05-04 | ||
@@ -5,0 +31,0 @@ |
@@ -103,5 +103,8 @@ /// <reference types="@nextcloud/typings" /> | ||
* @param {object} [options] options object | ||
* @param {boolean} options.escape enable/disable auto escape of placeholders (by default enabled) | ||
* @param {boolean} options.sanitize enable/disable sanitization (by default enabled) | ||
* | ||
* @return {string} | ||
*/ | ||
declare function translate(app: string, text: string, vars?: Record<string, string | number>, number?: number, options?: TranslationOptions): string; | ||
declare function translate(app: string, text: string, vars?: TranslationVariables, number?: number, options?: TranslationOptions): string; | ||
export { translate as t } | ||
@@ -148,2 +151,13 @@ export { translate } | ||
/** @notExported */ | ||
declare interface TranslationVariableReplacementObject<T> { | ||
/** The value to use for the replacement */ | ||
value: T; | ||
/** Overwrite the `escape` option just for this replacement */ | ||
escape: boolean; | ||
} | ||
/** @notExported */ | ||
declare type TranslationVariables = Record<string, string | number | TranslationVariableReplacementObject<string | number>>; | ||
/** | ||
@@ -150,0 +164,0 @@ * Unregister all translations of an app |
{ | ||
"name": "@nextcloud/l10n", | ||
"version": "3.0.1", | ||
"version": "3.1.0", | ||
"description": "Nextcloud L10n helpers for apps and libraries", | ||
@@ -5,0 +5,0 @@ "type": "module", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
144185
1232