Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(#621) Plural translation starting and ending with a variables fails #640

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

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.

@stackblitz
Copy link

stackblitz bot commented Mar 25, 2023

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!

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.

None yet

2 participants