From 690822b6ac16bb4a16136685e78a0d7d2e9cad58 Mon Sep 17 00:00:00 2001 From: Christian Kaisermann Date: Tue, 19 Nov 2019 21:35:49 -0300 Subject: [PATCH] =?UTF-8?q?refactor:=20=F0=9F=92=A1=20include=20generic=20?= =?UTF-8?q?locales=20on=20id=20not=20found=20message?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/client/index.ts | 8 +++++++- test/client/index.test.ts | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/client/index.ts b/src/client/index.ts index 453cbff..2d4a3b6 100644 --- a/src/client/index.ts +++ b/src/client/index.ts @@ -59,7 +59,13 @@ const formatMessage: Formatter = (id, options = {}) => { const message = lookupMessage(id, locale) if (!message) { - console.warn(`[svelte-i18n] The message "${id}" was not found in the locale "${locale}".`) + console.warn( + `[svelte-i18n] The message "${id}" was not found in "${locale + .split('-') + .map((_, i, arr) => arr.slice(0, i + 1).join('-')) + .reverse() + .join('", "')}".`, + ) if (defaultValue != null) return defaultValue return id } diff --git a/test/client/index.test.ts b/test/client/index.test.ts index d20a4dd..e872f95 100644 --- a/test/client/index.test.ts +++ b/test/client/index.test.ts @@ -137,8 +137,8 @@ describe('utilities', () => { }) it('should get the fallback locale', () => { - expect(getClientLocale({ navigator: false, fallback: 'pt' })).toBe('pt') - expect(getClientLocale({ hash: 'locale', fallback: 'pt' })).toBe('pt') + expect(getClientLocale({ navigator: false, default: 'pt' })).toBe('pt') + expect(getClientLocale({ hash: 'locale', default: 'pt' })).toBe('pt') }) })