You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I just tried new starter kits and noticed that there is no built-in support for localization. If you create a website in another language or in multiple languages you have to search for texts in all components and update them all.
for example the vue starter kit's `VerifyEmail´ component looks like this:
<script setup lang="ts">
// ...
</script>
<template>
<AuthLayouttitle="Verify email"description="Please verify your email address by clicking on the link we just emailed to you.">
<Headtitle="Email verification" />
<divv-if="status === 'verification-link-sent'"class="mb-4 text-center text-sm font-medium text-green-600">
A new verification link has been sent to the email address you provided during registration.
</div>
<form@submit.prevent="submit"class="space-y-6 text-center">
<Button:disabled="form.processing"variant="secondary">
<LoaderCirclev-if="form.processing"class="h-4 w-4 animate-spin" />
Resend verification email
</Button>
<TextLink:href="route('logout')"method="post"as="button"class="mx-auto block text-sm"> Log out </TextLink>
</form>
</AuthLayout>
</template>
To make the site multilingual you have to replace all texts with keys and add : to attributes everywhere.
I would like to propose a change to handling texts. Instead of writing texts hard coded in the components, define them all in a file using keys and use the keys in the components. After changes VerifyEmail component would look like this:
exportconsttranslations={verify_email: 'Verify email',email_verification: 'Email verification',verify_email_from_email_button: 'Please verify your email address by clicking on the link we just emailed to you.',new_verification_link_sent_to_email: 'A new verification link has been sent to the email address you provided during registration.',resend_verification_email: 'Resend verification email',log_out: 'Log out',}asconst;typeTranslationKey=keyoftypeoftranslations&string;exportconst__=(key: TranslationKey,replace?: Record<string,string|number>)=>{if(!(keyintranslations)){returnkey;}letres=translations[key]asstring;if(replace){for(constkinreplace){res=res.replace(`:${k}`,replace[k]asstring);}}returnres;};
if I want to add german support, all I have to do is to modify this file. No need to modify all components.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi everyone,
I just tried new starter kits and noticed that there is no built-in support for localization. If you create a website in another language or in multiple languages you have to search for texts in all components and update them all.
for example the vue starter kit's `VerifyEmail´ component looks like this:
To make the site multilingual you have to replace all texts with keys and add
:
to attributes everywhere.I would like to propose a change to handling texts. Instead of writing texts hard coded in the components, define them all in a file using keys and use the keys in the components. After changes
VerifyEmail
component would look like this:and here
translations.ts
file:if I want to add german support, all I have to do is to modify this file. No need to modify all components.
Results:
page
objectLooking forward to hearing your thoughts!
Beta Was this translation helpful? Give feedback.
All reactions