Skip to content

Conversation

@ben12
Copy link
Contributor

@ben12 ben12 commented Mar 25, 2023

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[x] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[x] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other... Please describe:

What is the current behavior?

Issue Number: #621

What is the new behavior?

To allow variable at start or end of plural translations (ex: {count, plural, =1 {1 person} other {{count} people}}), we add some forbidden characters for parameters name:

export interface TranslocoConfig {
[...]
  interpolation?: [start: string, end: string, forbiddenChars?: string];
}

Default configuration become:

export const defaultConfig: Omit<
  Required<TranslocoConfig>,
  'scopeMapping' | 'fallbackLang'
> = {
[...]
  interpolation: ['{{', '}}', '{}'],
};

So in {count, plural, =1 {1 person} other {{count} people}}, {{count} people}} will no longer be processed as variable.

Does this PR introduce a breaking change?

[x] Yes
[ ] No

Translation keys using braces are now forbidden.

Other information

I have implemented the check for forbidden key characters in transloco-validator with its unit tests.

@bolt-new-by-stackblitz
Copy link

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@ben12
Copy link
Contributor Author

ben12 commented May 16, 2023

@shaharkazaz Ready for review

@shaharkazaz
Copy link
Collaborator

@ben12 Thank you for the PR and the heads up, I missed this PR.
IDK when I'll be able to review but I'll try to reach it as soon as I have the time!

@ben12 ben12 force-pushed the ben12/issue621 branch 2 times, most recently from f35d22f to edbd685 Compare August 6, 2023 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants