mirror of
https://github.com/cupcakearmy/svelte-i18n.git
synced 2024-11-16 09:59:58 +01:00
docs: ✏️ add TOCs to some docs
This commit is contained in:
parent
fd97e89782
commit
08eb1554f3
@ -1,3 +1,17 @@
|
||||
<!-- @import "[TOC]" {cmd="toc" depthFrom=1 depthTo=6 orderedList=false} -->
|
||||
|
||||
<!-- code_chunk_output -->
|
||||
|
||||
- [Message syntax](#message-syntax)
|
||||
- [`$format` or `$_` or `$t`](#format-or-_-or-t)
|
||||
- [`$time(number: Date, options: MessageObject)`](#timenumber-date-options-messageobject)
|
||||
- [`$date(date: Date, options: MessageObject)`](#datedate-date-options-messageobject)
|
||||
- [`$number(number: number, options: MessageObject)`](#numbernumber-number-options-messageobject)
|
||||
- [Formats](#formats)
|
||||
- [Accessing formatters directly](#accessing-formatters-directly)
|
||||
|
||||
<!-- /code_chunk_output -->
|
||||
|
||||
### Message syntax
|
||||
|
||||
Under the hood, `formatjs` is used for localizing your messages. It allows `svelte-i18n` to support the ICU message syntax. It is strongly recommended to read their documentation about it.
|
||||
@ -74,7 +88,7 @@ Formats a date object into a time string with the specified format. Please refer
|
||||
<!-- 11:45:00 PM -->
|
||||
```
|
||||
|
||||
#### `$date(date: Date, options: MessageObject)`
|
||||
### `$date(date: Date, options: MessageObject)`
|
||||
|
||||
`import { date } from 'svelte-i18n'`
|
||||
|
||||
@ -88,7 +102,7 @@ Formats a date object into a string with the specified format. Please refer to t
|
||||
<!-- Apr 24, 2019 -->
|
||||
```
|
||||
|
||||
#### `$number(number: number, options: MessageObject)`
|
||||
### `$number(number: number, options: MessageObject)`
|
||||
|
||||
`import { number } from 'svelte-i18n'`
|
||||
|
||||
|
@ -1,5 +1,18 @@
|
||||
### Getting started
|
||||
|
||||
<!-- @import "[TOC]" {cmd="toc" depthFrom=4 depthTo=6 orderedList=false} -->
|
||||
|
||||
<!-- code_chunk_output -->
|
||||
|
||||
- [1. Locale dictionaries](#1-locale-dictionaries)
|
||||
- [2. Adding locale dictionaries](#2-adding-locale-dictionaries)
|
||||
- [2.1 Synchronous](#21-synchronous)
|
||||
- [2.2 Asynchronous](#22-asynchronous)
|
||||
- [3. Initializing](#3-initializing)
|
||||
- [4. Localizing your app](#4-localizing-your-app)
|
||||
|
||||
<!-- /code_chunk_output -->
|
||||
|
||||
#### 1. Locale dictionaries
|
||||
|
||||
A locale dictionary is a regular JSON object which contains message definitions for a certain language.
|
||||
|
@ -1,4 +1,22 @@
|
||||
#### init
|
||||
<!-- @import "[TOC]" {cmd="toc" depthFrom=4 depthTo=4 orderedList=false} -->
|
||||
|
||||
<!-- code_chunk_output -->
|
||||
|
||||
- [`init`](#init)
|
||||
- [`getLocaleFromHostname`](#getlocalefromhostname)
|
||||
- [`getLocaleFromPathname`](#getlocalefrompathname)
|
||||
- [`getLocaleFromNavigator`](#getlocalefromnavigator)
|
||||
- [`getLocaleFromQueryString`](#getlocalefromquerystring)
|
||||
- [`getLocaleFromHash`](#getlocalefromhash)
|
||||
- [`addMessages`](#addmessages)
|
||||
- [`register`](#register)
|
||||
- [`waitLocale`](#waitlocale)
|
||||
- [`getDateFormatter`/`getTimeFormatter`/`getNumberFormatter`](#getdateformattergettimeformattergetnumberformatter)
|
||||
- [`getMessageFormatter`](#getmessageformatter)
|
||||
|
||||
<!-- /code_chunk_output -->
|
||||
|
||||
#### `init`
|
||||
|
||||
> `import { init } from 'svelte-i18n'`
|
||||
|
||||
@ -68,7 +86,7 @@ init({
|
||||
<!-- 123.456,79 € -->
|
||||
```
|
||||
|
||||
#### getLocaleFromHostname
|
||||
#### `getLocaleFromHostname`
|
||||
|
||||
> `import { getLocaleFromHostname } from 'svelte-i18n'
|
||||
|
||||
@ -87,7 +105,7 @@ init({
|
||||
})
|
||||
```
|
||||
|
||||
#### getLocaleFromPathname
|
||||
#### `getLocaleFromPathname`
|
||||
|
||||
> `import { getLocaleFromPathname } from 'svelte-i18n'
|
||||
|
||||
@ -107,7 +125,7 @@ init({
|
||||
})
|
||||
```
|
||||
|
||||
#### getLocaleFromNavigator
|
||||
#### `getLocaleFromNavigator`
|
||||
|
||||
> `import { getLocaleFromNavigator } from 'svelte-i18n'
|
||||
|
||||
@ -127,7 +145,7 @@ init({
|
||||
})
|
||||
```
|
||||
|
||||
#### getLocaleFromQueryString
|
||||
#### `getLocaleFromQueryString`
|
||||
|
||||
> `import { getLocaleFromQueryString } from 'svelte-i18n'
|
||||
|
||||
@ -145,7 +163,7 @@ init({
|
||||
})
|
||||
```
|
||||
|
||||
#### getLocaleFromHash
|
||||
#### `getLocaleFromHash`
|
||||
|
||||
> `import { getLocaleFromHash } from 'svelte-i18n'
|
||||
|
||||
@ -165,7 +183,7 @@ init({
|
||||
})
|
||||
```
|
||||
|
||||
#### addMessages
|
||||
#### `addMessages`
|
||||
|
||||
`import { addMessages } from 'svelte-i18n`
|
||||
|
||||
@ -195,7 +213,7 @@ addMessages('pt', { field_2: 'Sobrenome' })
|
||||
}
|
||||
```
|
||||
|
||||
#### register
|
||||
#### `register`
|
||||
|
||||
> `import { register } from 'svelte-i18n'`
|
||||
|
||||
@ -214,7 +232,7 @@ register('pt', () => import('./_locales/pt.json'))
|
||||
|
||||
See [how to asynchronously load dictionaries](/svelte-i18n/blob/master/docs#22-asynchronous).
|
||||
|
||||
#### waitLocale
|
||||
#### `waitLocale`
|
||||
|
||||
> `import { waitLocale } from 'svelte-i18n'`
|
||||
|
||||
@ -243,7 +261,7 @@ Executes the queue of `locale`. If the queue isn't resolved yet, the same promis
|
||||
|
||||
### Low level API
|
||||
|
||||
#### getDateFormatter / getTimeFormatter / getNumberFormatter
|
||||
#### `getDateFormatter`/`getTimeFormatter`/`getNumberFormatter`
|
||||
|
||||
> `import { getDateFormatter, getNumberFormatter, getTimeFormatter } from 'svelte-i18n'`
|
||||
|
||||
@ -268,7 +286,7 @@ getNumberFormatter(
|
||||
|
||||
Each of these methods return their respective [`Intl.xxxxFormatter`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects#Internationalization) variant. Click [here](/docs/formatting.md#accessing-formatters-directly) for an example of usage.
|
||||
|
||||
#### getMessageFormatter
|
||||
#### `getMessageFormatter`
|
||||
|
||||
> `import { getMessageFormatter } from 'svelte-i18n'`
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user