Skip to content

Amplify Gen2 Authenticator - Language

0

I am developing an app using Amplify Gen2 - and Vue3... While signingin (or creating an account) authneticator is always english. I want the authenticator language to be set from the app.

asked a year ago206 views

1 Answer
0
    When using the Authenticator component with Amplify Gen 2 and Vue 3, the default language is indeed English. However, you can customize the language of the Authenticator to match your app's language preferences.

    To change the language of the Authenticator, you'll need to use the Amplify UI library, which provides customization options for the Authenticator component. While the exact implementation might vary slightly between React and Vue, the general approach is similar.

    Here's a general outline of how you can set the language for the Authenticator:

    1. First, make sure you've installed the necessary Amplify UI package for Vue.

    2. In your Vue component where you're using the Authenticator, you can pass in a 'services' prop to the Authenticator component. This prop allows you to override certain behaviors, including text strings.

    3. You can create a translation object with key-value pairs for all the text strings used in the Authenticator UI.

    4. Pass this translation object to the Authenticator component through the 'services' prop.

    The exact syntax might look something like this:

    ```vue
    <template>
      <Authenticator :services="services">
        <!-- Your app content -->
      </Authenticator>
    </template>

    <script>
    import { Authenticator } from '@aws-amplify/ui-vue';

    export default {
      components: { Authenticator },
      data() {
        return {
          services: {
            formFields: {
              signIn: {
                username: {
                  label: 'Votre email',
                  placeholder: 'Entrez votre email',
                },
                password: {
                  label: 'Mot de passe',
                  placeholder: 'Entrez votre mot de passe',
                },
              },
              // Add more translations for other forms and fields
            },
          },
        };
      },
    };
    </script>
    ```

    This approach allows you to customize the text for each field and button in the Authenticator UI. You can extend this to cover all the text used in the Authenticator, effectively changing its language to match your app's language.

    Remember to provide translations for all relevant fields and messages to ensure a consistent language experience throughout the authentication process.
  

Sources
Fullstack TypeScript: Reintroducing AWS Amplify | Front-End Web & Mobile
Quickstart - AWS Amplify Gen 2 Documentation
Using the Authenticator - AWS Amplify Gen 2 Documentation

answered a year ago

  • There is no standard language package from Apmlify for most popular languages? hard to believe!

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.