Skip to content

Commit

Permalink
Merge pull request #566 from nextcloud/feat/docs
Browse files Browse the repository at this point in the history
Add missing documentation
  • Loading branch information
susnux authored Jan 22, 2023
2 parents 98ada53 + 7d61da5 commit 84feca3
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 84feca3

Please sign in to comment.