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

Avaliblity to set keySeperator #1695

Open
3 tasks done
zoey-kaiser opened this issue Jan 30, 2024 · 0 comments
Open
3 tasks done

Avaliblity to set keySeperator #1695

zoey-kaiser opened this issue Jan 30, 2024 · 0 comments
Labels
Status: Proposal Request for comments

Comments

@zoey-kaiser
Copy link

zoey-kaiser commented Jan 30, 2024

Clear and concise description of the problem

We are using a flat JSON as our style guide. This means we avoid nested objects and separate namespaces by a .:

Our setup

{
	"one.nested": "One nested",
}

Instead of

{
	"one": {
		"nested": "One nested",
	}
}

We wanted to use some linked messages in our translation file, but sadly it looks for the object, instead of the flat translation:

{
	"one.nested": "One nested",
	"two": "Hi @:one.nested" // cannot be found, as it is searching for the object, not the flat entry
}

Suggested solution

While looking into how we can tell i18n, that we do not use objects, I stumbled across their configuration keySeperator (scroll down on this page or search for it: https://www.i18next.com/overview/configuration-options)

As per them they state it:

char to separate keys. If working with a flat JSON, it's recommended to set this to false.

Which seems like it would resolve our issue.

Alternative

As a workaround, we defined the reused translations with an _ instead of a ., however this is not nice, breaks conventions and causes confusion.

Additional context

We use nuxt-i18n, which wraps this library and allows us to pass any configs we want to this library. After searching for a way to set the keySeperator, i was sadly left unsuccessful.

Therefore my question is, how can we set the i18n options, that are set on init, inside vue i18n or where can I disable the key seperator, so it works for our project. If this does not exist, it would be amazing to have!

I had already brough this up in a discussion (#1693), however this did not gain any traction, which is why I wanted to try again with an issue! I hope this is alright.

Thank you so much in advance ❤️

Validations

@zoey-kaiser zoey-kaiser added the Status: Proposal Request for comments label Jan 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Proposal Request for comments
Projects
None yet
Development

No branches or pull requests

1 participant