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

I18n setup #189

Merged
merged 9 commits into from
Aug 18, 2021
Merged

I18n setup #189

merged 9 commits into from
Aug 18, 2021

Conversation

eddiekeller
Copy link
Contributor

Issue #, if available:

n/a

Description of changes:

adding initial setup for i18n support. only added translated text to the SignIn page for now until we decide that this is a good path forward. screenshots showing japanese and french -

Screen Shot 2021-08-17 at 1 36 33 PM

Screen Shot 2021-08-17 at 1 36 59 PM

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@eddiekeller eddiekeller temporarily deployed to ci August 17, 2021 20:54 Inactive
@eddiekeller eddiekeller temporarily deployed to ci August 17, 2021 20:54 Inactive
Copy link
Contributor

@ericclemmons ericclemmons left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eddiekeller you've done it again!

This is looking great! Some small nits that I'd like your opinion on, but the side-effects usage is the one change that we should consider before merging.

@@ -1,7 +1,8 @@
import { useAuth } from '../../../hooks';
import { I18n } from '@aws-amplify/core';
import { getAliasInfoFromContext } from '@aws-amplify/ui-core';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Somebody did Organize Imports ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unorganized imports give me gas :)

packages/react/index.tsx Outdated Show resolved Hide resolved
Copy link
Contributor

@wlee221 wlee221 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All lgtm 🚢 Just got some general nits, but nothing worth blocking over. Thanks @eddiekeller!

@@ -0,0 +1,312 @@
/*
* Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we change it to 2017-2021, or do we even need this header?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

copy and pasted from the old copyright in the JS repo. not sure if we need it. None of the other files in this new repo have it.

Comment on lines +22 to +23
'Enter your username': 'Geben Sie Ihren Benutzernamen ein',
'Enter your password': 'Geben Sie Ihr Passwort ein',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While working on this PR, did you find any missing translations that should be added here?

e.g. we would need to add Enter your email and Enter your password eventually.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't looked at all the screens yet - just sign in for now. But you're right! I'm sure we will need to add some / modify some eventually.

},

es: {
'Sign in to your account': 'Iniciar sesíon',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: I'm wondering if we should have a type that enumerates these translation keys to ensure that language translations are in parity.

Perhaps something like:

type TranslationEntry = 
  | 'Sign in to your account'
  | 'Resend Code'
  // ...

type BilingualDict = Record<TranslationEntry, string>;

type SupportedLanguages = 'de' | 'fr' | 'es' | 'zh' | 'ja';

type Dict = Record<SupportedLanguages, BilingualDict>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bringing this up because I see that "Signing In" only exist in German.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can add in typing...but I wonder if "forcing" parity between the languages would work. We are going to rely on the open source community for translation support, and I'm picturing a scenario when a contributor will want to add a new string, or only a couple strings of translations. In that case, forcing parity between all languages might almost act like a blocker. Maybe I'm thinking about it wrong.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, that's a fair point. I agree, let's keep it as is now. Maybe we can do Partial<> just so that we have vscode autocomplete, but this is not an issue now and I don't want it to be a blocker.

<Input name="password" required type="password" />
<Box>
<Text>Forgot your password?</Text>{' '}
<Text>{I18n.get('Forgot your password? ')}</Text>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: imo space ' ' shouldn't be added in translation and instead be handled by UI.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think translations actually make more sense. Example - Japanese doesn't use spaces. Forcing spaces in the UI would be breaking certain languages. If the intent of the space isn't an actual linguistic space but whitespace between elements, then we should be handling that via CSS instead.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, but I think with that component the space was used to put spacing between "Forgot your password" and the link if I remember correctly. Which I think should be handled through css or {{' '}}

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

Successfully merging this pull request may close these issues.

3 participants