Skip to content

Commit

Permalink
Remove the 'docs' subpath
Browse files Browse the repository at this point in the history
  • Loading branch information
andrii-bodnar committed Jan 24, 2023
1 parent 9d69153 commit 9bb72eb
Show file tree
Hide file tree
Showing 32 changed files with 188 additions and 187 deletions.
2 changes: 1 addition & 1 deletion website/docs/guides/dynamic-loading-catalogs.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Dynamic loading of message catalogs

[`I18nProvider`](/docs/ref/react#i18nprovider) doesn't assume anything about your app and it's your responsibility to load messages based on active language.
[`I18nProvider`](/docs/ref/react.md#i18nprovider) doesn't assume anything about your app and it's your responsibility to load messages based on active language.

Here's an example of a basic setup with a dynamic load of catalogs.

Expand Down
2 changes: 1 addition & 1 deletion website/docs/guides/excluding-build-files.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Excluding message catalog build files

[`lingui extract`](/docs/ref/cli#extract) command creates temporary message catalogs per each source file. Also, [`lingui compile`](/docs/ref/cli#compile) command generates compiled message catalogs from source ones. All these files can be safely ignored from VCS and linters.
[`lingui extract`](/docs/ref/cli.md#extract) command creates temporary message catalogs per each source file. Also, [`lingui compile`](/docs/ref/cli.md#compile) command generates compiled message catalogs from source ones. All these files can be safely ignored from VCS and linters.

Can be safely ignored because this files must be created every time you deploy to production, so we encourage to use CI methods to automatize this process. If you commit it you will produce conflicts, which somebody will need to solve, in this minimized and transpired (basically unreadable to human) file. In summary, please, **compile always your catalogs**.

Expand Down
16 changes: 8 additions & 8 deletions website/docs/guides/optimized-components.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ React components can be optimized to skip updates implementing `shouldComponentU
The two cases to handle are:

1. Translations inside optimized component.
2. Optimized component is wrapped in [`withI18n`](/docs/ref/react#withi18n) to translate text attributes.
2. Optimized component is wrapped in [`withI18n`](/docs/ref/react.md#withi18n) to translate text attributes.

Let's take a look at both scenarios.

Expand All @@ -27,20 +27,20 @@ Imagine following React tree:
</OptimizedComponent>
```

When active language is changed or message catalog is updated, `OptimizedComponent` will probably skip the update, because it's props don't change. It means that all children of `OptimizedComponent` won't be updated, including [`Trans`](/docs/ref/react#trans) component.
When active language is changed or message catalog is updated, `OptimizedComponent` will probably skip the update, because it's props don't change. It means that all children of `OptimizedComponent` won't be updated, including [`Trans`](/docs/ref/react.md#trans) component.

By default, all [`Trans`](/docs/ref/react#trans) components listen for language and catalog changes and update themselves when it happens. Even if `OptimizedComponent` skips update, [`Trans`](/docs/ref/react#trans) component is updated correctly.
By default, all [`Trans`](/docs/ref/react.md#trans) components listen for language and catalog changes and update themselves when it happens. Even if `OptimizedComponent` skips update, [`Trans`](/docs/ref/react.md#trans) component is updated correctly.

Also, [`withI18n`](/docs/ref/react#withi18n) HOC listens for language and catalog changes, but this behavior can be disabled by passing `update = false` option:
Also, [`withI18n`](/docs/ref/react.md#withi18n) HOC listens for language and catalog changes, but this behavior can be disabled by passing `update = false` option:

``` jsx
// Component won't listen for language/catalog changes
export default withI18n({ update = false })(Component)
```

## Optimized component wrapped in [`withI18n`](/docs/ref/react#withi18n)
## Optimized component wrapped in [`withI18n`](/docs/ref/react.md#withi18n)

Component should be wrapped in [`withI18n`](/docs/ref/react#withi18n) HOC when it's required to access low-level i18n API. Common use-case is translation of attributes:
Component should be wrapped in [`withI18n`](/docs/ref/react.md#withi18n) HOC when it's required to access low-level i18n API. Common use-case is translation of attributes:

``` jsx
import * as React from 'react'
Expand All @@ -57,7 +57,7 @@ export default withI18n()(HeaderLink)

Content of link will be updated correctly as discussed in previous section. However, text attributes aren't components but only function calls, so they can't listen to changes of active language and catalog.

The trick here is to update whole component, but since it's a PureComponent, it does shallow comparison of props. [`withI18n`](/docs/ref/react#i18nprovider) HOC makes things easier by passing `i18nHash` to wrapped component. This hash is changed after every change of active language or catalog.
The trick here is to update whole component, but since it's a PureComponent, it does shallow comparison of props. [`withI18n`](/docs/ref/react.md#i18nprovider) HOC makes things easier by passing `i18nHash` to wrapped component. This hash is changed after every change of active language or catalog.

If you have your own implementation of `shouldComponentUpdate`, simply compare also `i18nHash`:

Expand All @@ -84,7 +84,7 @@ export default withI18n({ withHash = false })(Component)

## Summary

LinguiJS handles updates in and for Optimized components in most cases. If you want to disable this behavior, you can pass either `update = false` or `withHash = false` to [`withI18n`](/docs/ref/react#withi18n) HOC.
LinguiJS handles updates in and for Optimized components in most cases. If you want to disable this behavior, you can pass either `update = false` or `withHash = false` to [`withI18n`](/docs/ref/react.md#withi18n) HOC.

`update` fixes updates if component has optimized parents while
`withHash` fixes updates for intermediate optimized children.
Expand Down
4 changes: 2 additions & 2 deletions website/docs/guides/plurals.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ When `numBooks == 1`, this will render as *1 book* and for `numBook == 2` it wil

> Funny fact for non-English speakers: In English, 0 uses plural form too, *0 books*.
Under the hood, [`plural`](/docs/ref/macro#plural) is replaced with low-level [`i18n._`](/docs/ref/core#i18n._). For production, the above example will become:
Under the hood, [`plural`](/docs/ref/macro.md#plural) is replaced with low-level [`i18n._`](/docs/ref/core.md#i18n._). For production, the above example will become:

``` js
i18n._('{numBooks, plural, one {# book} other {# books}}', { numBooks })
```

When we extract messages from source code using [`lingui-cli`](/docs/tutorials/cli), we get:
When we extract messages from source code using [`lingui-cli`](/docs/tutorials/cli.md), we get:

``` icu-message-format
{numBooks, plural, one {# book} other {# books}}
Expand Down
6 changes: 3 additions & 3 deletions website/docs/guides/pseudolocalization.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ There is built in support for [pseudolocalization](https://en.wikipedia.org/wiki
## Configuration

To setup pseudolocalization add [`pseudoLocale`](/docs/ref/conf#pseudolocale) to your lingui [`configuration file`](/docs/ref/conf):
To setup pseudolocalization add [`pseudoLocale`](/docs/ref/conf.md#pseudolocale) to your lingui [`configuration file`](/docs/ref/conf.md):

```json
{
Expand All @@ -20,13 +20,13 @@ To setup pseudolocalization add [`pseudoLocale`](/docs/ref/conf#pseudolocale) to
}
```

[`pseudoLocale`](/docs/ref/conf#pseudolocale) option can be any string that is in `locale`
[`pseudoLocale`](/docs/ref/conf.md#pseudolocale) option can be any string that is in `locale`

Examples: `en-PL`, `pseudo-LOCALE`, `pseudolocalization` or `en-UK`

## Create pseudolocalization

[`pseudoLocale`](/docs/ref/conf#pseudolocale) string has to be in [`locales`](/docs/ref/conf#locales) config as well. Otherwise, no folder and no pseudolocalization is going to be created. After running [`extract`](/docs/ref/cli#extract) verify that the folder has been created. The pseudolocalization is automatically created on [`compile`](/docs/ref/cli#compile) from messages in order specified in [this cli section](/docs/tutorials/cli#preparing-catalogs-for-production). In case fallbackLocales has been used, the pseudolocalization is going to be created from translated fallbacklocale.
[`pseudoLocale`](/docs/ref/conf.md#pseudolocale) string has to be in [`locales`](/docs/ref/conf.md#locales) config as well. Otherwise, no folder and no pseudolocalization is going to be created. After running [`extract`](/docs/ref/cli.md#extract) verify that the folder has been created. The pseudolocalization is automatically created on [`compile`](/docs/ref/cli.md#compile) from messages in order specified in [this cli section](/docs/tutorials/cli.md#preparing-catalogs-for-production). In case fallbackLocales has been used, the pseudolocalization is going to be created from translated fallbacklocale.

## Switch browser into specified pseudoLocale

Expand Down
2 changes: 1 addition & 1 deletion website/docs/guides/testing.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Testing

Components using [`Trans`](/docs/ref/react#trans), [`withI18n`](/docs/ref/react#withi18n) or [`useLingui`](/docs/ref/react#uselingui) require access to the context of [`I18nProvider`](/docs/ref/react#i18nprovider). How you can wrap your component with the I18nProvider depends on the test library you use.
Components using [`Trans`](/docs/ref/react.md#trans), [`withI18n`](/docs/ref/react.md#withi18n) or [`useLingui`](/docs/ref/react.md#uselingui) require access to the context of [`I18nProvider`](/docs/ref/react.md#i18nprovider). How you can wrap your component with the I18nProvider depends on the test library you use.

Here is a working example with [react-testing-library](https://testing-library.com/docs/react-testing-library/intro/), using the [wrapper-property](https://testing-library.com/docs/react-testing-library/api#wrapper):

Expand Down
4 changes: 2 additions & 2 deletions website/docs/guides/typescript.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ In your `webpack.config.js`, use both `babel-loader` and `ts-loader` for Typescr
```

:::note
If you are not using `.babelrc` file, keep in mind that by running [`lingui extract`](/docs/ref/cli#extract), the Webpack config is not used. To supply babel options for the extraction process use [`extractBabelOptions`](/docs/ref/conf#extractbabeloptions) configuration option.
If you are not using `.babelrc` file, keep in mind that by running [`lingui extract`](/docs/ref/cli.md#extract), the Webpack config is not used. To supply babel options for the extraction process use [`extractBabelOptions`](/docs/ref/conf.md#extractbabeloptions) configuration option.
:::

[`compileNamespace`](/docs/ref/conf#compilenamespace) must be set to `ts` (ES6 default export) in the Lingui config otherwise compiled catalogs can't be imported using ES `import`, but rather CommonJS `require`:
[`compileNamespace`](/docs/ref/conf.md#compilenamespace) must be set to `ts` (ES6 default export) in the Lingui config otherwise compiled catalogs can't be imported using ES `import`, but rather CommonJS `require`:

``` js
{
Expand Down
4 changes: 2 additions & 2 deletions website/docs/index.md → website/docs/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ Keep your code clean and readable, while the library uses battle-tested and powe

### Universal

Use it everywhere. [`@lingui/core`](/docs/ref/core) provides the essential intl functionality which works in any JavaScript project while [`@lingui/react`](/docs/ref/react) offers components to leverage React rendering.
Use it everywhere. [`@lingui/core`](/docs/ref/core.md) provides the essential intl functionality which works in any JavaScript project while [`@lingui/react`](/docs/ref/react.md) offers components to leverage React rendering.

### Full rich-text support

Use React components inside localized messages without any limitation. Writing rich-text messages is as easy as writing JSX.

### Powerful tooling

Manage the whole intl workflow using Lingui [CLI](/docs/tutorials/cli). It extracts messages from source code, validates messages coming from translators and checks that all messages are translated before shipping to production.
Manage the whole intl workflow using Lingui [CLI](/docs/tutorials/cli.md). It extracts messages from source code, validates messages coming from translators and checks that all messages are translated before shipping to production.

### Unopinionated

Expand Down
12 changes: 6 additions & 6 deletions website/docs/misc/react-intl.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,17 @@ Let's go back to the previous example:
</p>
```

All we need to do is to wrap the message in a [`Trans`](/docs/ref/macro#trans) macro:
All we need to do is to wrap the message in a [`Trans`](/docs/ref/macro.md#trans) macro:

``` html
<p>
<Trans id="msg.docs">Read the <a href="/docs">documentation</a>.</Trans>
</p>
```

The macro then parses the [`Trans`](/docs/ref/macro#trans) macro children and generates `defaults` and `components` props automatically in the form described in the previous section.
The macro then parses the [`Trans`](/docs/ref/macro.md#trans) macro children and generates `defaults` and `components` props automatically in the form described in the previous section.

This is extremely useful when adding i18n to an existing project. All we need is to wrap all messages in [`Trans`](/docs/ref/macro#trans) macro.
This is extremely useful when adding i18n to an existing project. All we need is to wrap all messages in [`Trans`](/docs/ref/macro.md#trans) macro.

Let's compare it with [react-intl](https://github.com/yahoo/react-intl) solution to see the difference:

Expand Down Expand Up @@ -133,7 +133,7 @@ Let's take a look at the original example from [react-intl](https://github.com/y
/>
```

Using [LinguiJS](https://github.com/lingui/js-lingui) macros, we could combine [`Trans`](/docs/ref/macro#trans), [`Plural`](/docs/ref/macro#plural-1) components and [`i18n.number`](/docs/ref/core#i18n.number) macro:
Using [LinguiJS](https://github.com/lingui/js-lingui) macros, we could combine [`Trans`](/docs/ref/macro.md#trans), [`Plural`](/docs/ref/macro.md#plural-1) components and [`i18n.number`](/docs/ref/core.md#i18n.number) macro:

``` jsx
<Trans id="welcome">
Expand Down Expand Up @@ -193,7 +193,7 @@ Custom IDs are supported as well:
```
:::note
To inject `i18n` object into props, you need to use HOC [`withI18n`](/docs/ref/react#withi18n). It's very similar to `injectIntl` from [react-intl](https://github.com/yahoo/react-intl). Alternatively, you can also use `I18n` render prop component.
To inject `i18n` object into props, you need to use HOC [`withI18n`](/docs/ref/react.md#withi18n). It's very similar to `injectIntl` from [react-intl](https://github.com/yahoo/react-intl). Alternatively, you can also use `I18n` render prop component.
:::
## External message catalog
Expand All @@ -202,7 +202,7 @@ Let's say our app has been internationalized and we now want to send the message
[react-intl](https://github.com/yahoo/react-intl) comes with the Babel plugin which extracts messages from individual files, but it's up to you to merge them into one file which you can send to translators.
[LinguiJS](https://github.com/lingui/js-lingui) provides handy [`CLI`](/docs/tutorials/cli) which extracts messages and merges them with any existing translations. Again, the story doesn't end here.
[LinguiJS](https://github.com/lingui/js-lingui) provides handy [`CLI`](/docs/tutorials/cli.md) which extracts messages and merges them with any existing translations. Again, the story doesn't end here.
## Compiling messages
Expand Down
6 changes: 3 additions & 3 deletions website/docs/ref/catalog-formats.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Catalog formats

Catalog format (configured by [`format`](/docs/ref/conf#format) option) refers to file format of offline catalog. This format is never used in production, because it's compiled into JS module. The reason behind this build step is that choice of catalog format depends on individual internationalization workflow. On the other hand runtime catalog should be as simple as possible so it parsed quickly without additional overhead.
Catalog format (configured by [`format`](/docs/ref/conf.md#format) option) refers to file format of offline catalog. This format is never used in production, because it's compiled into JS module. The reason behind this build step is that choice of catalog format depends on individual internationalization workflow. On the other hand runtime catalog should be as simple as possible so it parsed quickly without additional overhead.

## PO File (recommended)

Expand Down Expand Up @@ -66,8 +66,8 @@ With `po-gettext`, plural messages are exported in the following way, depending

Note that this format comes with several caveats and should therefore only be used if using ICU plurals in PO files is not an option:

- Nested/multiple plurals in one message as shown in [`plural`](/docs/ref/macro#plural) are not supported as it cannot be expressed with gettext plurals. Messages containing nested/multiple formats will not be output correctly.
- [`select`](/docs/ref/macro#select) and [`selectOrdinal`](/docs/ref/macro#selectordinal) cannot be expressed with gettext plurals, but the original ICU format is still saved to the `msgid`/`msgstr` properties. To disable the warning that this might not be the expected behavior, include `{ disableSelectWarning: true }` in the [`formatOptions`](/docs/ref/conf#formatoptions).
- Nested/multiple plurals in one message as shown in [`plural`](/docs/ref/macro.md#plural) are not supported as it cannot be expressed with gettext plurals. Messages containing nested/multiple formats will not be output correctly.
- [`select`](/docs/ref/macro.md#select) and [`selectOrdinal`](/docs/ref/macro.md#selectordinal) cannot be expressed with gettext plurals, but the original ICU format is still saved to the `msgid`/`msgstr` properties. To disable the warning that this might not be the expected behavior, include `{ disableSelectWarning: true }` in the [`formatOptions`](/docs/ref/conf.md#formatoptions).
- Source/development languages with more than two plurals could experience difficulties when no custom IDs are used, as gettext cannot have more than two plurals cases identifying an item (`msgid` and `msgid_plural`).
- Gettext doesn't support plurals for negative and fractional numbers even though some languages have special rules for these cases.

Expand Down
14 changes: 7 additions & 7 deletions website/docs/ref/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

### `--config <config>`

Path to LinguiJS configuration file. If not set, the default file is loaded as described in [LinguiJS configuration](/docs/ref/conf) reference.
Path to LinguiJS configuration file. If not set, the default file is loaded as described in [LinguiJS configuration](/docs/ref/conf.md) reference.

## Commands

Expand Down Expand Up @@ -76,19 +76,19 @@ Remove obsolete messages from catalogs. Message becomes obsolete when it's missi
#### `--overwrite` {#extract-overwrite}
Update translations for [`sourceLocale`](/docs/ref/conf#sourcelocale) from source.
Update translations for [`sourceLocale`](/docs/ref/conf.md#sourcelocale) from source.
#### `--format <format>` {#extract-format}
Format of message catalogs (see [`format`](/docs/ref/conf#format) option).
Format of message catalogs (see [`format`](/docs/ref/conf.md#format) option).
#### `--locale <locale>` {#extract-locale}
Only extract data for the specified locale.
#### `--convert-from <format>` {#extract-convert-from}
Convert message catalogs from previous format (see [`format`](/docs/ref/conf#format) option).
Convert message catalogs from previous format (see [`format`](/docs/ref/conf.md#format) option).
#### `--verbose` {#extract-verbose}
Expand Down Expand Up @@ -141,19 +141,19 @@ Fail if a catalog has missing translations.
#### `--format <format>` {#compile-format}
Format of message catalogs (see [`format`](/docs/ref/conf#format) option).
Format of message catalogs (see [`format`](/docs/ref/conf.md#format) option).
#### `--verbose` {#compile-verbose}
Prints additional information.
#### `--namespace` {#compile-namespace}
Specify namespace for compiled message catalogs (also see [`compileNamespace`](/docs/ref/conf#compilenamespace) for global configuration).
Specify namespace for compiled message catalogs (also see [`compileNamespace`](/docs/ref/conf.md#compilenamespace) for global configuration).
#### `--typescript` {#compile-typescript}
Is the same as using [`compileNamespace`](/docs/ref/conf#compilenamespace) with the value "ts". Generates a `{compiledFile}.d.ts` and the compiled file is generated using the extension .ts
Is the same as using [`compileNamespace`](/docs/ref/conf.md#compilenamespace) with the value "ts". Generates a `{compiledFile}.d.ts` and the compiled file is generated using the extension .ts
#### `--watch` {#compile-watch}
Expand Down
Loading

0 comments on commit 9bb72eb

Please sign in to comment.