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

export ref that holds current language #192

Open
Fuzzyma opened this issue Nov 5, 2024 · 11 comments
Open

export ref that holds current language #192

Fuzzyma opened this issue Nov 5, 2024 · 11 comments

Comments

@Fuzzyma
Copy link

Fuzzyma commented Nov 5, 2024

Following the spirit of vue, it feels strange to call "getActiveLanguage" to get the current locale.
Can you please add an export with a ref that holds the active language as well?
That would also enable us to write links that change when the locale gets changed.
Atm, I dont see any way of doing that especially there is no way to detect if a locale has changed.

Usage:

<script>
import { currentLocale } from 'laravel-vue-i18n';
</script>

<template>
  <Link :href="route('localized.home', { locale: currentLocale })">Home</Link>
</template>
@SecretChakra
Copy link

Wow, this is exactly what im trying to solve.

  • for this Issue

@Fuzzyma
Copy link
Author

Fuzzyma commented Nov 5, 2024

Lol did you have the same issue at the same time and found this 10minutes after its creation? :D
Your link seems broken tho

@SecretChakra
Copy link

I will describe actually what im trying to solve:
vue.js + ssr
have made a LanguageSwitcher.vue component
ok working for 2 languages, but trying to understand how to change url based on locales.

in my case Italian + English

Default: (ITA)
Second Lang: (EN)

But ofc url is not changing. I dont know maybe you archived this?
Im pretty new in whole ecosystem (lara+vue) but its seems really similar to what Vitepress has archived.

in my mind im trying to handle "translated content" as md files, and UI translation with this package.

What do you think?
Im pretty disperate at this point xD

@Fuzzyma
Copy link
Author

Fuzzyma commented Nov 5, 2024

I ended up routing to the localized route (/en/ or /de/) with a normal link. So it's a full reload of the page to the English or German version

@SecretChakra
Copy link

Just for your information

https://github.com/jetstreamlabs/zora

2morow morning I will try this one.

Since we are forced to use Standart routes why don't give it a chance?

It's sad because this package was working well. But lacks this Standart behavior. Thanks mate

@SecretChakra
Copy link

SecretChakra commented Nov 6, 2024

Nah, im stick with laravel-vue-i18n at this moment. But i think we need author's help in order to get laravel locales to work with his package. Please @xiCO2k can you provide some instructions?

If we get some example it would be highly appreciated.

@xiCO2k
Copy link
Owner

xiCO2k commented Nov 7, 2024

Looks like its something that I can consider adding, can you add a PR with that addition?

Thanks.

@Fuzzyma
Copy link
Author

Fuzzyma commented Nov 9, 2024

If you give me some pointers where the current locale gets set and where it gets read I can create a pr

@SecretChakra
Copy link

@Fuzzyma can you please share some example regarding locales?

@SecretChakra
Copy link

Ok i think i have solved. Now on locale change, your plugin changes translation.
Oh yeah.. 1 week after i managed to properly make it work.
Great stuff.

@Fuzzyma
Copy link
Author

Fuzzyma commented Nov 12, 2024

@SecretChakra this issue is about solving the issue at hand. Please refrain of sharing your personal journey. Most of your posts are not meaningful to solving the issue at hand (and every time a notification is send to the author). I am an OSS maintainer myself and this kind of conversation puts stress on the maintainer which results in even less engagement.

Happy that you figured it out tho. Lets get back to topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants