Skip to content

Commit

Permalink
refactor: Remove interpolation from defaultConfig (#1543)
Browse files Browse the repository at this point in the history
  • Loading branch information
isaachinman authored Dec 4, 2021
1 parent bb58629 commit bf1f608
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"run-example": "yarn build && cd examples/simple && yarn && yarn dev",
"run-example:prod": "yarn build:examples/simple && yarn --cwd examples/simple start",
"run-cypress": "cypress run --config-file cypress/cypress.json",
"test": "yarn check-types && yarn clean && yarn build && yarn build:examples/simple && bundlesize && NODE_ENV=test jest --passWithNoTests --maxWorkers=1 --silent",
"test": "yarn check-types && yarn clean && yarn build && yarn build:examples/simple && bundlesize && NODE_ENV=test jest --maxWorkers=1 --silent",
"test:e2e": "start-server-and-test 'yarn --cwd examples/simple start' 3000 'yarn run-cypress'",
"contributors:check": "all-contributors check",
"contributors:add": "all-contributors add",
Expand Down
2 changes: 2 additions & 0 deletions src/config/createConfig.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ describe('createConfig', () => {
expect(config.strictMode).toEqual(true)
expect(config.use).toEqual([])
expect(config.react?.useSuspense).toEqual(false)
expect(config.interpolation).toBeUndefined()

expect(fs.existsSync).toHaveBeenCalledTimes(1)
expect(fs.readdirSync).toHaveBeenCalledTimes(1)
Expand Down Expand Up @@ -199,6 +200,7 @@ describe('createConfig', () => {
expect(config.strictMode).toEqual(true)
expect(config.use).toEqual([])
expect(config.react?.useSuspense).toEqual(false)
expect(config.interpolation).toBeUndefined()
})

it('deep merges backend', () => {
Expand Down
5 changes: 0 additions & 5 deletions src/config/defaultConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ export const defaultConfig = {
get initImmediate(): boolean {
return process.browser && typeof window !== 'undefined'
},
interpolation: {
escapeValue: false,

This comment has been minimized.

Copy link
@adrai

adrai Dec 4, 2021

Member

did you remove the escapeValue intentionally? default in i18next is true: https://github.com/i18next/i18next/blob/master/src/defaults.js#L54
but for react default is better to be set to false: https://github.com/i18next/react-i18next/blob/master/example/react/src/i18n.js#L22

This comment has been minimized.

Copy link
@isaachinman

isaachinman Dec 4, 2021

Author Contributor

Is there any downside to leaving the default value of true when using React?

This comment has been minimized.

Copy link
@adrai

This comment has been minimized.

Copy link
@adrai

adrai Dec 4, 2021

Member

for example try to change the escapeValue to true here and check the output: https://codesandbox.io/s/react-i18next-example-8fw5x?file=/src/i18n.js:1213-1218

This comment has been minimized.

Copy link
@isaachinman

isaachinman Dec 4, 2021

Author Contributor

Quick review?

#1563

Thanks very much for finding this!

format: (value: string, format: string): string => (format === 'uppercase' ? value.toUpperCase() : value),
formatSeparator: ',',
},
load: 'currentOnly',
localeExtension: LOCALE_EXTENSION,
localePath: LOCALE_PATH,
Expand Down

1 comment on commit bf1f608

@vercel
Copy link

@vercel vercel bot commented on bf1f608 Dec 4, 2021

Choose a reason for hiding this comment

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

Please sign in to comment.