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

feat: add angular tutorial article #437

Merged
merged 20 commits into from
Aug 10, 2023
Merged

Conversation

Gunkev
Copy link
Contributor

@Gunkev Gunkev commented Jul 12, 2023

Tolgee angular tutorial article

@netlify
Copy link

netlify bot commented Jul 12, 2023

👷 Deploy request for tolgee-web pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit beb54a0


Once you hit the save button, it will generate an API key under the Integrate section. Make sure to save the key somewhere. You will be using it later.

## Step 3: Install Tolgee
Copy link
Contributor

Choose a reason for hiding this comment

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

Creation of angular project should be separate step


Add the `NgxTolgeeModule` in the import section and provide a Tolgee instance in the providers. Our default application language is en you can change it to fr or es depending on your preferences. Lastly, we import the environment variable we added earlier which will help us to communicate with the server.

## Step 6: Translate Your Texts and Export the files:
Copy link
Contributor

Choose a reason for hiding this comment

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

From now on, it feels like you still need to get what's the most important benefit of Tolgee. With the toggle-SDK installed, you can add the keys by alt + clicking them. So you can add the key to the code and then translate it directly in the running app. You don't have to go to the platform and add it manualy. https://tolgee.io/js-sdk/in-context

I actually don't blame you for not getting it correctly. It's more that our documentation could be structured better so the reader who directly goes to the angular section finds out about this. Sorry! 😢

@JanCizmar
Copy link
Contributor

Hey! Sorry, for that I wasn't reviewing the Vue.js article, but can you fix the same issues there?

@Gunkev Gunkev requested a review from JanCizmar July 17, 2023 19:52
Copy link
Contributor

@JanCizmar JanCizmar left a comment

Choose a reason for hiding this comment

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

Much better. Please fix accordingly and sync the Angular and Vue! Your work is much appreciated! Thanks a lot! 🚀 🐁


![Translation dialog](/img/blog/vue-tutorial/translation_dialog.png)

Once you have added your translations, click on the save button to store your translations in the Tolgee Platform.
Copy link
Contributor

Choose a reason for hiding this comment

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

You can also mention, that you can add screenshots in the same time and Tolgee automatically collects context of the translations for usage with the Tolgee translator. https://tolgee.io/blog/tolgee-ai-translator

Copy link
Contributor

Choose a reason for hiding this comment

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

New user's might be confused, why we use this approach, so it would be great if you supported it with few arguments.

  1. It's faster then edit the localization .json or add it to the platform manually
  2. To fix such key, you have just to click the string. Any team member can do that with Tolgee chrome plugin. Not only developers.
  3. You can generate screenshots by clicking the camera. This way future translators will know the context and will translate the string correctly


Once you have added your translations, click on the save button to store your translations in the Tolgee Platform.

Equally, you can follow the same process to update your translations.
Copy link
Contributor

Choose a reason for hiding this comment

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

Also, for importing lot of translations from large codebase, there is the CLI extract command. (It works only for React now, but we are working on Vue and Angular implementations) https://tolgee.io/tolgee-cli/extraction/syncing-strings


![List of translations](/img/blog/vue-tutorial/translation_list.png)

Tolgee also allows you to export your translations in `json` files. In your Tolgee dashboard, click on export in the left menu, then select the languages you want then click on export
Copy link
Contributor

Choose a reason for hiding this comment

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

You should mention here, that this can be done automatically in CI/CD tool via REST API or Tolgee CLI. So user's wont think that they have to manually export it all the time.

@Gunkev Gunkev requested a review from JanCizmar July 19, 2023 18:39
Copy link
Contributor

@JanCizmar JanCizmar left a comment

Choose a reason for hiding this comment

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

It's almost fine. Thanks a lot! 🚀

Please sync the changes with both the articles.

Thanks! 🤘


### Automated Translation

Tolgee can help you automate your translation process. It has a platform that integrates with machine translation services, such as Google Translate and AWS, to automatically translate your content. This ensures that your translations are accurate and consistent.
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be great to mention Tolgee translator here. With it, the translation can be almost autonomous!!! https://tolgee.io/blog/tolgee-ai-translator


- The DevTools() is used for in-context translating in dev mode
- The FormatSimple() enables you to pass variables into translations
- The BackendFetch() fetches data from the custom backend
Copy link
Contributor

Choose a reason for hiding this comment

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

You actually don't use the BackendFetch plugin and you don't need it in most cases. Only thing the plugin does is that if you published your i18n data for example on https://example.com/i18/en.json, etc., it can fetch the data from there. But it's not something you should cover in this article.


In case you have a lot of translations from large codebase, you can use the [CLI extract command](https://tolgee.io/tolgee-cli/extraction/syncing-strings). (It works only for React now, but we are working on Vue and Angular implementations)

To export your translations, click on the Export menu in your left menu
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, I didn't mention this before. This part should be called "Preparing for production". And it also should cover, how you provide the data if you don't specify your API key. You should also mention that the API should never be leaked.

When you build the app for production, you export the data (prefarably using the CLI) and then you provide it as a staticData configuration property. (or you can use BackendFetch), but that's not the optimal way we recommend. You can read more about that here: https://tolgee.io/js-sdk/integrations/angular/installation#preparing-for-production

and here:

https://tolgee.io/js-sdk/providing-static-data


Now, navigate to `src` folder in your angular project and create `i18n` folder. Add the content of the extracted file to this folder.

![Create I18n folder](/img/blog/angular-tutorial/angular_i18n.png)
Copy link
Contributor

Choose a reason for hiding this comment

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

You don't have to show the full contents of the files here. It's very long for the article.

@Gunkev Gunkev requested a review from JanCizmar July 26, 2023 19:47
@JanCizmar JanCizmar merged commit b7309a0 into tolgee:main Aug 10, 2023
1 of 2 checks passed
stepan662 pushed a commit that referenced this pull request Aug 11, 2023
Tolgee angular tutorial article
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.

2 participants