Comments (14)
Fixed on v2.0.1
. Please, see https://github.com/kaisermann/svelte-i18n/wiki#setting-the-initial-locale to set the initial and fallback locales in a simpler way 😁
from svelte-i18n.
I'm downgrading until you figure out how to fix your bugs.
from svelte-i18n.
I wasn't very good of words while explaining what that prop does. The fallback
locale is only used as a possible return value of getClientLocale
. There's currently no way to define a default locale in the way you want. Going to work on this soon 😁
from svelte-i18n.
Change language in chrome. I get an error now and blank screen. IT now shows EN but if I choose DE (which I have translations for) I get an error.
import { locale, register, getClientLocale } from 'svelte-i18n'
import { de, fr, en } from './i18n'
// // Define a locale dictionary
// dictionary.set({
// de,
// fr,
// en,
// })
// This is a store, so we can subscribe to its changes
locale.subscribe(() => {
console.log('locale change')
})
// svelte-i18n exports a method to help getting the current client locale
locale.set(
getClientLocale({
// the fallback locale, if didn't find any
fallback: 'en',
// set to 'true' to check the 'window.navigator.language'
navigator: true,
// // set the key name to look for a locale on 'window.location.search'
// // 'example.com?locale=en-US'
// search: 'lang'
}),
)
register('de', () => de)
register('fr', () => fr)
register('en', () => en)
// Set the current locale to en-US
// locale.set('en')
from svelte-i18n.
from svelte-i18n.
Can you provide a repro? It would help a lot to solve your issue 😁
For that example above: check the wiki link I sent you, it shows the correct way of adding dictionaries and setting the fallback locale.
- if you're importing/requiring all your dictionaries at build time, use the
addMessages
method. If you want to asynchronously load them, you can useregister
, but you will need to wait for the defined locale dictionary to load. See https://github.com/kaisermann/svelte-i18n/wiki#setting-the-initial-locale 😁 - Call
setInitialLocale
instead oflocale.set
andgetClientLocale.
import { addMessages, setInitialLocale } from 'svelte-i18n'
import { de, fr, en } from './i18n'
// Add messages to each locale dictionary
addMessages('de', de)
addMessages('fr', fr)
addMessages('en', en)
// set the initial locale based on the user's 'navigator.language'
// and configure the fallback locale to english
setInitialLocale({
fallback: 'en',
navigator: true,
})
from svelte-i18n.
Uncaught Error: path is not a valid object path
at objectResolvePath (object-resolve-path.js:17)
at U (i18n.mjs:1)
at Object.q [as $_] (i18n.mjs:1)
at create_fragment$1 (Home.svelte:1)
at init (index.mjs:1346)
at new Home (Home.svelte:2)
at create_fragment (Router.svelte:168)
at init (index.mjs:1346)
at new Router (Router.svelte:158)
at create_fragment$r (Topnav.svelte:10)```
This is what I get. site is https://puump.com
from svelte-i18n.
Can you share a minimal reproduction of what you're doing in your project? It's kind of hard to know what's exactly happening just by that error message. Are you using message ids with special characters, such as -
, @
?
from svelte-i18n.
yes of course i have special characters. i use english as the key, as is common practice.
<p>{$_('Completely private, pay with Bitcoin. Cancel when you want.')}</p>
This worked fine the other day, but now it seems to throw an error.
from svelte-i18n.
For a shallow dictionary, using english as keys should be working. I'll rewrite all the tests in the following week, hopefully it'll cover your issues.
It will take less time to debug and fix your issue if you stop just demanding a fix and instead help me help you. Just be patient.
from svelte-i18n.
so are we supposed to use 2.0.3 or 1.1.2?
from svelte-i18n.
Keep using the version you're using for now. I'm already working on the v2 fixes and a migration guide from v1 to v2.
from svelte-i18n.
Version 2.1.0
was released. I've also updated the docs and made a quick migration guide from v1 to v2: https://github.com/kaisermann/svelte-i18n/wiki/Migration
Let me know if your issue is fixed after migrating.
from svelte-i18n.
working now! thank you.
from svelte-i18n.
Related Issues (20)
- Sveltekit: Update translation outside of component
- Variable inside html isn't replaced HOT 1
- Inform about unused language keys HOT 1
- When I hover over a <a> the site language changes to the default language. HOT 1
- `intl-getcanocicallocales` is probably not a good idea HOT 2
- CJS / ESM conflict HOT 22
- Change log version comparison links are off
- Production build using svelte-i18n ^3.7.4 throws "Named export 'IntlMessageFormat' not found." HOT 6
- Problems with LIB check in cli extractor HOT 1
- Sapper reference in Getting Started guide
- Allow to restrict some parts of the i18n file to unauthorized users in SvelteKit. HOT 3
- Is it possible when registering several json files to overwrite the previous key contents with latest file?
- Docs on how to use variables in translation strings HOT 1
- How to disable AM/PM in $time formatter
- Leading zeros for day/month when formatting date values
- Add a register store?
- Build error when deploying in vercel
- Provide a Readable<string> instead of pure string
- Svelte 5 support
- Disable automatic "lang" attribute setting
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from svelte-i18n.