Skip to content

Commit 247a7ea

Browse files
committed
bug #822 [Translator] Type and documentation fixes (Kocal)
This PR was squashed before being merged into the 2.x branch. Discussion ---------- [Translator] Type and documentation fixes | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Tickets | Fix #... <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead --> | License | MIT <!-- Replace this notice by a short README for your feature/bugfix. This will help people understand your PR and can be used as a start for the documentation. Additionally (see https://symfony.com/releases): - Always add tests and ensure they pass. - Never break backward compatibility (see https://symfony.com/bc). - Features and deprecations must be submitted against branch main. --> When working on the demo page, I've faced an issue about `Date` which was unuasable as translation parameter, but it should as we can use it to format date/datetime. The documentation rendering was a bit broken too, I'm not familiar with RST, but it should be fixed. Also, when running `yarn install`, the `yarn.lock` change, so I commited it aswell. Commits ------- 8f472d5 [Translator] Type and documentation fixes
2 parents 446728b + 8f472d5 commit 247a7ea

File tree

4 files changed

+18
-7
lines changed

4 files changed

+18
-7
lines changed

src/Translator/assets/dist/translator.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export type TranslationsType = Record<DomainType, {
44
parameters: ParametersType;
55
}>;
66
export type NoParametersType = Record<string, never>;
7-
export type ParametersType = Record<string, string | number> | NoParametersType;
7+
export type ParametersType = Record<string, string | number | Date> | NoParametersType;
88
export type RemoveIntlIcuSuffix<T> = T extends `${infer U}+intl-icu` ? U : T;
99
export type DomainsOf<M> = M extends Message<infer Translations, LocaleType> ? keyof Translations : never;
1010
export type LocaleOf<M> = M extends Message<TranslationsType, infer Locale> ? Locale : never;

src/Translator/assets/src/translator.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export type LocaleType = string;
1414

1515
export type TranslationsType = Record<DomainType, { parameters: ParametersType }>;
1616
export type NoParametersType = Record<string, never>;
17-
export type ParametersType = Record<string, string | number> | NoParametersType;
17+
export type ParametersType = Record<string, string | number | Date> | NoParametersType;
1818

1919
export type RemoveIntlIcuSuffix<T> = T extends `${infer U}+intl-icu` ? U : T;
2020
export type DomainsOf<M> = M extends Message<infer Translations, LocaleType> ? keyof Translations : never;

src/Translator/doc/index.rst

+6-5
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,17 @@ Configuring the default locale
6161
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6262

6363
By default, the default locale is ``en`` (English) that you can configure through many ways (in order of priority):
64-
1. With ``setLocale('your-locale')`` from ``@symfony/ux-translator`` package
65-
2. Or with ``<html data-symfony-ux-translator-locale="your-locale">`` attribute
66-
3. Or with ``<html lang="your-locale">`` attribute
64+
65+
#. With ``setLocale('your-locale')`` from ``@symfony/ux-translator`` package
66+
#. Or with ``<html data-symfony-ux-translator-locale="your-locale">`` attribute
67+
#. Or with ``<html lang="your-locale">`` attribute
6768

6869
Importing and using translations
6970
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7071

71-
If you use the Symfony Flex recipe, you can import the ``trans()`` function and your translations in your assets from the file `assets/translator.js`.
72+
If you use the Symfony Flex recipe, you can import the ``trans()`` function and your translations in your assets from the file ``assets/translator.js``.
7273

73-
Translations are available as named exports, by using the translation's id transformed in uppercase snake-case (e.g.: `my.translation` becomes `MY_TRANSLATION`),
74+
Translations are available as named exports, by using the translation's id transformed in uppercase snake-case (e.g.: ``my.translation`` becomes ``MY_TRANSLATION``),
7475
so you can import them like this:
7576

7677
.. code-block:: javascript

yarn.lock

+10
Original file line numberDiff line numberDiff line change
@@ -6412,6 +6412,16 @@ supports-preserve-symlinks-flag@^1.0.0:
64126412
resolved "https://registry.yarnpkg.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz#6eda4bd344a3c94aea376d4cc31bc77311039e09"
64136413
integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==
64146414

6415+
svelte-jester@^2.3:
6416+
version "2.3.2"
6417+
resolved "https://registry.yarnpkg.com/svelte-jester/-/svelte-jester-2.3.2.tgz#9eb818da30807bbcc940b6130d15b2c34408d64f"
6418+
integrity sha512-JtxSz4FWAaCRBXbPsh4LcDs4Ua7zdXgLC0TZvT1R56hRV0dymmNP+abw67DTPF7sQPyNxWsOKd0Sl7Q8SnP8kg==
6419+
6420+
svelte@^3.0:
6421+
version "3.58.0"
6422+
resolved "https://registry.yarnpkg.com/svelte/-/svelte-3.58.0.tgz#d3e6f103efd6129e51c7d709225ad3b4c052b64e"
6423+
integrity sha512-brIBNNB76mXFmU/Kerm4wFnkskBbluBDCjx/8TcpYRb298Yh2dztS2kQ6bhtjMcvUhd5ynClfwpz5h2gnzdQ1A==
6424+
64156425
swup@^2.0, swup@^2.0.13:
64166426
version "2.0.19"
64176427
resolved "https://registry.yarnpkg.com/swup/-/swup-2.0.19.tgz#dfb5c0f3d63e21089403fcad8d117c87a2b7eab0"

0 commit comments

Comments
 (0)