Skip to content

Commit

Permalink
feat(docs): Add some missing documentation and export Translations
Browse files Browse the repository at this point in the history
…type

Signed-off-by: Ferdinand Thiessen <rpm@fthiessen.de>
  • Loading branch information
susnux committed Jan 20, 2023
1 parent dfc8888 commit 7d61da5
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@ console.warn(n('my-app', 'Got an error', 'Got multiple errors', 2));
```
*/

export type { Translations } from './registry'

export * from './translation'
export * from './date'
32 changes: 32 additions & 0 deletions lib/registry.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,39 @@
/// <reference types="@nextcloud/typings" />

/**
* Translation bundle
*
* @example For German translation
* ```json
{
"some": "einige",
"_%n tree_::_%n trees_": [
"%n Baum",
"%n Bäume"
]
}
```
*/
export type Translations = Record<string, string | string[] | undefined>

/**
* Function for getting plural form index from translated number
*
* @param number Input number to translate
* @return Index of translation plural form
* @example For most languages, like English or German
* ```js
(number:number) => number === 1 ? 0 : 1
```
*/
export type PluralFunction = (number: number) => number

/**
* Extended window interface with translation registry
* Exported just for internal testing purpose
*
* @private
*/
export interface NextcloudWindowWithRegistry extends Nextcloud.v25.WindowWithGlobals {
_oc_l10n_registry_translations?: Record<string, Translations>
_oc_l10n_registry_plural_functions?: Record<string, PluralFunction>
Expand Down

0 comments on commit 7d61da5

Please sign in to comment.