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

feat(i18n): allow custom interpolation options for i18n #4727

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

zleight1
Copy link

Allow for specifying custom interpolation options for i18n. This is useful for custom interpolation patterns, such as {{ and }}. Tests added, and scoped to the i18n module.

Closes #4726

🔎 Overview

Adds the ability to use custom interpolation options, such as prefix and suffix.

This allows the library to comply with the default i18next standard.

🤓 Code snippets/examples (if applicable)

configure({
  generateMessage: localize(
    'en',
    {
      messages: {
        between: 'The {{field}} field must be between 0:{{min}} and 1:{{max}}',
      },
    },
    {
      prefix: '{{',
      suffix: '}}',
    },
  ),
});

Issues affected

closes #4726

Allow for specifying custom interpolation options for i18n.
This is useful for custom interpolation patterns, such as `{{` and `}}`.
Tests added, and scoped to the i18n module.

Closes logaretm#4726
Copy link

codecov bot commented Apr 15, 2024

Codecov Report

Attention: Patch coverage is 91.48936% with 4 lines in your changes are missing coverage. Please review.

Project coverage is 89.89%. Comparing base (2a0881f) to head (75e229f).

Files Patch % Lines
packages/i18n/src/index.ts 90.32% 3 Missing ⚠️
packages/i18n/src/utils.ts 90.90% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4727      +/-   ##
==========================================
+ Coverage   89.87%   89.89%   +0.01%     
==========================================
  Files          93       93              
  Lines        7676     7709      +33     
  Branches     1360     1362       +2     
==========================================
+ Hits         6899     6930      +31     
- Misses        770      772       +2     
  Partials        7        7              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@zleight1
Copy link
Author

If accepted I'll update the docs as well

@zleight1
Copy link
Author

@logaretm - is there something I can do to help with making this a reality?

If there's some reason you would not want this, please let me know why so I can understand more.

Thanks!

Copy link
Owner

@logaretm logaretm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay, Thank you @zleight1, This looks alright to me. I have no concerns here other than the test file seems to have changed significantly. I would have assumed this would need to add a test case or two but the changes here are too significant with some tests altered, if possible lets keep everything as-is and only add the needed test cases for this interpolation feature.

Once that is fixed we can merge this right away.

@@ -4,58 +4,59 @@ import { required, between } from '@/rules';
import { localize, setLocale } from '@/i18n';
import { mountWithHoc, setValue, flushPromises } from '../../vee-validate/tests/helpers';

defineRule('required', required);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too many changes here, maybe due to having describe? If so then lets revert that and only include the test cases for this PR.

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.

Ability to customize interpolation prefix/suffix
2 participants