Skip to content

Commit

Permalink
fix(lint): Fix typos and formatting issues with eslint --fix
Browse files Browse the repository at this point in the history
Signed-off-by: Ferdinand Thiessen <rpm@fthiessen.de>
  • Loading branch information
susnux committed Jan 12, 2023
1 parent 9a8f441 commit 12e00e1
Show file tree
Hide file tree
Showing 6 changed files with 177 additions and 177 deletions.
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = {
'ts-jest', {
tsconfig: 'tests/tsconfig.json',
},
]
],
},
transformIgnorePatterns: [],
}
2 changes: 1 addition & 1 deletion lib/date.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// <reference types="@nextcloud/typings" />

declare var window: Nextcloud.v24.WindowWithGlobals
declare let window: Nextcloud.v24.WindowWithGlobals

/**
* Get the first day of the week
Expand Down
3 changes: 1 addition & 2 deletions lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
/**
* This module provides all functions for the `OC.L10N` namespace
*
*
* @packageDocumentation
* @module @nextcloud/l10n
* @example
* ```js
import { translate as t, translatePlural as n } from '@nextcloud/l10n'
console.log(t('my-app', 'Hello {name}', { name: 'J. Doe' }));
const count = 2;
console.warn(n('my-app', 'Got an error', 'Got multiple errors', 2));
Expand Down
16 changes: 11 additions & 5 deletions lib/registry.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export type Translations = Record<string, string | undefined>
export type PluralFunction = (number: number) => number

declare var window: {
declare let window: {
_oc_l10n_registry_translations: Record<string, Translations>
_oc_l10n_registry_plural_functions: Record<string, PluralFunction>
}
Expand All @@ -13,18 +13,20 @@ interface AppTranslations {

/**
* Check if translations and plural function are set for given app
*
* @param {string} appId the app id
* @return {boolean}
*/
export function hasAppTranslations(appId: string) {
return (
window._oc_l10n_registry_translations?.[appId] !== undefined &&
window._oc_l10n_registry_plural_functions?.[appId] !== undefined
window._oc_l10n_registry_translations?.[appId] !== undefined
&& window._oc_l10n_registry_plural_functions?.[appId] !== undefined
)
}

/**
* Register new, or extend available, translations for an app
*
* @param {string} appId the app id
* @param {object} translations the translations list
* @param {Function} pluralFunction the plural function
Expand All @@ -43,6 +45,7 @@ export function registerAppTranslations(

/**
* Unregister all translations and plural function for given app
*
* @param {string} appId the app id
*/
export function unregisterAppTranslations(appId: string) {
Expand All @@ -52,13 +55,14 @@ export function unregisterAppTranslations(appId: string) {

/**
* Get translations bundle for given app and current locale
*
* @param {string} appId the app id
* @return {object}
*/
export function getAppTranslations(appId: string): AppTranslations {
if (
typeof window._oc_l10n_registry_translations === 'undefined' ||
typeof window._oc_l10n_registry_plural_functions === 'undefined'
typeof window._oc_l10n_registry_translations === 'undefined'
|| typeof window._oc_l10n_registry_plural_functions === 'undefined'
) {
console.warn('No OC L10N registry found')
return {
Expand All @@ -75,6 +79,7 @@ export function getAppTranslations(appId: string): AppTranslations {

/**
* Set new translations and plural function for an app
*
* @param {string} appId the app id
* @param {object} translations the translations list
* @param {Function} pluralFunction the plural function
Expand All @@ -90,6 +95,7 @@ function setAppTranslations(

/**
* Extend translations for an app
*
* @param {string} appId the app id
* @param {object} translations the translations list
* @param {Function} [pluralFunction] the plural function (will override old value if given)
Expand Down

0 comments on commit 12e00e1

Please sign in to comment.