Skip to content

feat: add translation hooks and packages - #1980

Merged
asyncapi-bot merged 14 commits into
asyncapi:masterfrom
anshgoyalevil:ssg
Aug 2, 2023
Merged

asyncapi-bot merged 14 commits into
asyncapi:masterfrom
anshgoyalevil:ssg

Conversation

@anshgoyalevil

Copy link
Copy Markdown
Member

Description

  • This PR adds the translation hooks and packages for configuring the i18n on the AsyncAPI website.
  • As per conversation with the mentor, the website would initially support i18n for German Language, and would gradually support more languages as the community contributes.
  • The fallback language is en
  • I have added the initial translation for the heroHeading on Landing Page to test the package. Would be adding more translations in the subsequent PRs.

Related issue(s)

fixes #1978

@netlify

netlify Bot commented Jul 22, 2023 •

Copy link
Copy Markdown

✅ Deploy Preview for asyncapi-website ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 27dccdf
🔍 Latest deploy log https://app.netlify.com/sites/asyncapi-website/deploys/64ca01b65f269e0008dd6c6f
😎 Deploy Preview https://deploy-preview-1980--asyncapi-website.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@github-actions

github-actions Bot commented Jul 22, 2023 •

Copy link
Copy Markdown

⚡️ Lighthouse report for the changes in this PR:

Category Score
🔴 Performance 27
🟢 Accessibility 98
🟢 Best practices 100
🟢 SEO 100
🔴 PWA 30

Lighthouse ran on https://deploy-preview-1980--asyncapi-website.netlify.app/

@derberg

derberg commented Jul 25, 2023

Copy link
Copy Markdown
Member

German 👀
Is there already someone volunteering to provide translation for German? Cause if it is Polish, we at least have people that could try to provide some simple translations, same for Spanish I guess

@anshgoyalevil

Copy link
Copy Markdown
Member Author

@derberg I was testing the translation thing, and sticked to the German Language.
Though I used Google Translator for that.

Would add Spanish Language (or maybe Polish) in the upcoming PRs.

@magicmatatjahu

Copy link
Copy Markdown
Member

@anshgoyalevil @derberg Yeah, it was my fault. I suggested German only for testing (we don't need the proper translation tbh, we can even use lorem ipsum on German texts). However if we wanna go with "production" translations we can go with Spanish or Polish from beginning. Sorry for that misunderstood!

@magicmatatjahu magicmatatjahu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Awesome! 🚀 I see some "problems" but overall it's great start. We need to remember (before merge) to disable the language switcher and also add the proper blockers in the crawler bots config to disable crawling (now) the translations. We will enable that in last PR :)

Comment thread components/Hero.js Resolved
Comment thread next.config.js Resolved
Comment thread next-i18next-static-site-config.js Resolved
Comment thread locales/en/common.json Resolved
Comment thread pages/[lang]/index.js Resolved
Comment thread components/navigation/NavBar.js Resolved
@anshgoyalevil

Copy link
Copy Markdown
Member Author

@magicmatatjahu Done with the changes. Thanks for the inputs 😄

Comment thread components/navigation/NavBar.js Resolved
Comment thread components/navigation/NavBar.js Resolved
Comment thread pages/[lang]/index.js Resolved
Comment thread pages/[lang]/index.js

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If you are migrating the file, can you please do the refactoring of this codebase in terms of formatting and spacing?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes sure.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done!

Comment thread lib/locales.js Outdated
Comment on lines +5 to +16
const locales = {};
languages.map((language) => {
locales[language] = {};

namespaces.map((namespace) => {
locales[language][namespace] = require("./../locales/" +
language +
"/" +
namespace +
".json");
});
});

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Kindly wrap this in a function and then return the required response from the function.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Actually, this is not my implementation. It is suggested by the plugin author since were in need to use the static site built due to Netlify restrictions.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you please share the source you are following to create this file?

IMHO, even if we have to implement such logic, I don't think it will make any difference while implementing it inside functions. Reason why I'm asking for making it as a function is that we should work on code quality as well, instead of just writing it as plain implementation of js. Also, it will be easier to add unit tests (later on) for this file.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done! I totally agree with your points.

I am following this package. Their one of the examples is what I tried imitating in our project.

The reason to use this package is that previously I was using the next-i18next package to handle the translation-related logic, and everything was going smoothly inside the local dev. environment.
As I pushed that code, it became useless because Netlify cannot process translations on the server, and need pre-generated translations.
Another option was to use a Node.JS environment to host the website, but that doesn't seem viable.

@anshgoyalevil

Copy link
Copy Markdown
Member Author

Thanks for the inputs @akshatnema 🚀
I will be making the changes like refactoring in subsequent PRs.
The purpose of this PR is to create a base over the other pages of the project, as you might have seen that currently, only the homepage is moved under [lang] directory, and that is because, as we would move towards translating other pages, they would also be moved under the [lang] folder.

This PR is ready to be merged. The scope of this PR is limited to:

  • Initialising translation hooks and packages
  • Creating a base structure for other pages of the project.
  • Creating the Language Selected in Navbar, which would be un-commented in the last PR, as per @magicmatatjahu

@akshatnema

Copy link
Copy Markdown
Member

@anshgoyalevil Kindly resolve the comments only if either the discussion made using the comment satisfies the reviewer or you made changes requested by the reviewer.

magicmatatjahu
magicmatatjahu previously approved these changes Aug 2, 2023

@magicmatatjahu magicmatatjahu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ok for me :) Please only change the label for Github button and we can merge :)

Comment thread components/buttons/GithubButton.js Resolved
@anshgoyalevil

Copy link
Copy Markdown
Member Author

Thanks @magicmatatjahu 😄. Changed the GitHub Button 🚀

@magicmatatjahu

magicmatatjahu commented Aug 2, 2023 •

Copy link
Copy Markdown
Member

@anshgoyalevil It still has Gtihub text - probably you changed the text inside navbar (and override default text):

image

Please fix that :)

It has to be:

image

@anshgoyalevil

Copy link
Copy Markdown
Member Author

@magicmatatjahu Sorry for that. Missed that. Fixed now

@magicmatatjahu

Copy link
Copy Markdown
Member

@akshatnema Hi! Could you check PR?

@magicmatatjahu

Copy link
Copy Markdown
Member

/rtm

@asyncapi-bot
asyncapi-bot merged commit 97f0446 into asyncapi:master Aug 2, 2023
@anshgoyalevil
anshgoyalevil deleted the ssg branch September 8, 2023 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: add translation package and hooks

5 participants