Skip to content

Commit 475fdd6

Browse files
fix: enableDebugKey display key (#1276)
* fix: enableDebugKey display key * fix: changeset
1 parent fa7626f commit 475fdd6

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

.changeset/khaki-turtles-move.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@scaleway/use-i18n': minor
3+
---
4+
5+
enableDebugKey should always return the key

packages/use-i18n/src/__tests__/usei18n.tsx

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -297,17 +297,11 @@ describe('i18n hook', () => {
297297
expect(result.current.t('test')).toEqual('test')
298298

299299
await waitFor(() => {
300-
expect(result.current.t('title')).toEqual(en.title)
301-
expect(result.current.t('subtitle')).toEqual(en.subtitle)
302-
expect(result.current.t('plurals', { numPhotos: 0 })).toEqual(
303-
'You have no photos.',
304-
)
305-
expect(result.current.t('plurals', { numPhotos: 1 })).toEqual(
306-
'You have one photo.',
307-
)
308-
expect(result.current.t('plurals', { numPhotos: 2 })).toEqual(
309-
'You have 2 photos.',
310-
)
300+
expect(result.current.t('title')).toEqual('title')
301+
expect(result.current.t('subtitle')).toEqual('subtitle')
302+
expect(result.current.t('plurals', { numPhotos: 0 })).toEqual('plurals')
303+
expect(result.current.t('plurals', { numPhotos: 1 })).toEqual('plurals')
304+
expect(result.current.t('plurals', { numPhotos: 2 })).toEqual('plurals')
311305
})
312306
})
313307

packages/use-i18n/src/usei18n.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -330,11 +330,11 @@ const I18nContextProvider = ({
330330
const translate = useCallback(
331331
(key: string, context?: ReactParamsObject<any>) => {
332332
const value = translations[currentLocale]?.[key] as string
333-
if (!value) {
334-
if (enableDebugKey) {
335-
return key
336-
}
333+
if (enableDebugKey) {
334+
return key
335+
}
337336

337+
if (!value) {
338338
return ''
339339
}
340340
if (context) {

0 commit comments

Comments
 (0)