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: update localization doc #1784

Merged
merged 1 commit into from
Jun 21, 2024
Merged

feat: update localization doc #1784

merged 1 commit into from
Jun 21, 2024

Conversation

sdo-1A
Copy link
Contributor

@sdo-1A sdo-1A commented May 14, 2024

Proposed change

Update documentation on localization

@sdo-1A sdo-1A requested a review from a team as a code owner May 14, 2024 13:44
Copy link

nx-cloud bot commented May 14, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit c7e3925. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 1 target

Sent with 💌 from NxCloud.

@github-actions github-actions bot added documentation Improvements or additions to documentation enhancement New feature or request project:@o3r/localization labels May 14, 2024

- Place your translation bundles either at your dedicated endpoint URL or inside your application's folder **src/assets/assets-otter/i18n**. The format of the bundles is a simple key/value pair object where key is the resource name and value its translation. The key naming convention is component selector followed by `.` (dot character) and any string of your choice.
It's always a good idea to respect certain naming conventions. For components, we prefix each key by the component selector to ensure the uniqueness of cross-components keys.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
It's always a good idea to respect certain naming conventions. For components, we prefix each key by the component selector to ensure the uniqueness of cross-components keys.
It's always a good idea to respect certain naming conventions. For components, we recommend to prefix each key by the component selector to ensure the uniqueness of cross-components keys.

maybe we can create a linter for that :)

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 will create an issue for this once the PR is merged

Copy link
Contributor Author

Choose a reason for hiding this comment

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


- Fallback language. In case some resource key does not exist in language X, the loader tries to fetch translation bundle from the endpoint location in fallback language Y in the first place and ends by loading json bundles from the application (root of dist folder **/** by default) if previous steps have failed (bundles output path in dist folder is also configurable via a shell option).
- Translations loader using a specific endpoint (external URL source such as a CMS for example) or defaulting to local translation bundles in the **src/assets/assets-otter/i18n** folder of your application. The input folder for bundles can be changed by configuration (via a shell option).
Copy link
Contributor

Choose a reason for hiding this comment

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

which shell option ? (not sure to know what it is)

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 changed to CLI option to be more clear (The assets folder for bundles can be changed by configuration (via a CLI option).), but I could remove this line if you don't find it necessary.


```typescript
You may also need to set up your http server to accept **CORS** and update the `connect-src` property of `csp.json` in your application.
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we really need to add that in our documentation ?
It's not related to Otter no ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not related to Otter but it could be useful during the setup of the localization.
What does everyone think?

Copy link
Contributor

Choose a reason for hiding this comment

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

It's good to add it if it helps the setup
You may also need -> it is not clear in the doc when and why this would be needed

docs/localization/LOCALIZATION.md Show resolved Hide resolved
docs/localization/LOCALIZATION.md Outdated Show resolved Hide resolved
docs/localization/LOCALIZATION.md Outdated Show resolved Hide resolved
docs/localization/LOCALIZATION.md Outdated Show resolved Hide resolved
@sdo-1A sdo-1A force-pushed the doc/localization branch 2 times, most recently from c86d582 to da302a9 Compare May 29, 2024 14:34
cpaulve-1A
cpaulve-1A previously approved these changes May 30, 2024
"defaultValue": "This is my default value 2"
},
"o3r-my-component-pres.someglobalkey1": {
"$ref": "../global.localization.json#/someglobalkey1"
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we are missing documentation to explain the purpose of using $ref

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is a line above this code snippet to explain why we can use $ref, should we add additional documentation?

```

### How to add RTL support in my app

The **TextDirectionService** has to be injected in `app.component.ts` as follows.
The `TextDirectionService` has to be injected in `app.component.ts` as follows:
Copy link
Contributor

Choose a reason for hiding this comment

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

To be discussed with the team how we can move it outside the app.component to not pollute it

fpaul-1A
fpaul-1A previously approved these changes Jun 18, 2024
@sdo-1A sdo-1A added this pull request to the merge queue Jun 21, 2024
Merged via the queue into main with commit 57f7aac Jun 21, 2024
28 checks passed
@sdo-1A sdo-1A deleted the doc/localization branch June 21, 2024 08:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request project:@o3r/localization
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants