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

Docs: The Proposal of Karmada Dashboard Automation i18n Tool which is Developed for OSPP 2024 Project. #119

Merged
merged 1 commit into from
Sep 10, 2024

Conversation

chouchongYHMing
Copy link
Contributor

What type of PR is this?
documentation

What this PR does / why we need it:
This is the proposal for auto i18n-tool.
Which issue(s) this PR fixes:
Fixes #53

Special notes for your reviewer:
It's for ospp 2024 project.
Does this PR introduce a user-facing change?:
No, It's just for developer.

- docs: the proposal of i18n tool

@karmada-bot karmada-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Sep 9, 2024
@warjiang
Copy link
Contributor

warjiang commented Sep 9, 2024

/assign

@warjiang
Copy link
Contributor

warjiang commented Sep 9, 2024

@chouchongYHMing plz resolve the problem of DCO


## Summary

Internationalization (also called i18n) is essential for software that aims to become global. During the development of the Karmada dashboard, we encountered inefficiencies, errors, and lack of engineering rigor in manually maintaining translation content (also called locales files). To solve these issues and meet the i18n needs of the Karmada dashboard project, we developed a ready-to-use automated i18n tool.
Copy link
Contributor

@warjiang warjiang Sep 9, 2024

Choose a reason for hiding this comment

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

we suffered from low efficiency、 easy to make mistakes、lack of engineering due to maintaining i18n translation (aka locales) manually.


## Summary

Internationalization (also called i18n) is essential for software that aims to become global. During the development of the Karmada dashboard, we encountered inefficiencies, errors, and lack of engineering rigor in manually maintaining translation content (also called locales files). To solve these issues and meet the i18n needs of the Karmada dashboard project, we developed a ready-to-use automated i18n tool.
Copy link
Contributor

Choose a reason for hiding this comment

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

out-of-the-box


## Motivation

During the development of the Karmada dashboard, early on, we maintained the locales files manually. If new Chinese content was added to the code, it required to replace by the corresponding i18n keys and functions. After that, a mapping of code points to the corresponding Chinese content was added to the Chinese locales file. Then translating the Chinese content and inserting a mapping of code points to the translated content in the locales files of the respective languages. When the project was small and the amount of Chinese characters was limited, the cost of manual maintenance was relatively acceptable. However, as the project scale expanded and the number of Chinese characters increased, the cost of manually maintaining locales files rose exponentially. Therefore, an automated i18n tool was needed to meet the i18n requirements of the Karmada dashboard. In the open source community, it was hard to find a ready-to-use i18n tool that perfectly supported the i18n needs of the Karmada dashboard. Therefore, we aimed to develop an automated i18n tool which is based on the perspective of the Karmada dashboard's i18n requirements, to satisfy the specific i18n needs of the Karmada dashboard.
Copy link
Contributor

Choose a reason for hiding this comment

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

we maintained the locales files manually in the early stages.


## Motivation

During the development of the Karmada dashboard, early on, we maintained the locales files manually. If new Chinese content was added to the code, it required to replace by the corresponding i18n keys and functions. After that, a mapping of code points to the corresponding Chinese content was added to the Chinese locales file. Then translating the Chinese content and inserting a mapping of code points to the translated content in the locales files of the respective languages. When the project was small and the amount of Chinese characters was limited, the cost of manual maintenance was relatively acceptable. However, as the project scale expanded and the number of Chinese characters increased, the cost of manually maintaining locales files rose exponentially. Therefore, an automated i18n tool was needed to meet the i18n requirements of the Karmada dashboard. In the open source community, it was hard to find a ready-to-use i18n tool that perfectly supported the i18n needs of the Karmada dashboard. Therefore, we aimed to develop an automated i18n tool which is based on the perspective of the Karmada dashboard's i18n requirements, to satisfy the specific i18n needs of the Karmada dashboard.
Copy link
Contributor

@warjiang warjiang Sep 9, 2024

Choose a reason for hiding this comment

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

we need to replace Chinese content with i18n keys and functions.


## Motivation

During the development of the Karmada dashboard, early on, we maintained the locales files manually. If new Chinese content was added to the code, it required to replace by the corresponding i18n keys and functions. After that, a mapping of code points to the corresponding Chinese content was added to the Chinese locales file. Then translating the Chinese content and inserting a mapping of code points to the translated content in the locales files of the respective languages. When the project was small and the amount of Chinese characters was limited, the cost of manual maintenance was relatively acceptable. However, as the project scale expanded and the number of Chinese characters increased, the cost of manually maintaining locales files rose exponentially. Therefore, an automated i18n tool was needed to meet the i18n requirements of the Karmada dashboard. In the open source community, it was hard to find a ready-to-use i18n tool that perfectly supported the i18n needs of the Karmada dashboard. Therefore, we aimed to develop an automated i18n tool which is based on the perspective of the Karmada dashboard's i18n requirements, to satisfy the specific i18n needs of the Karmada dashboard.
Copy link
Contributor

Choose a reason for hiding this comment

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

scale up


## Motivation

During the development of the Karmada dashboard, early on, we maintained the locales files manually. If new Chinese content was added to the code, it required to replace by the corresponding i18n keys and functions. After that, a mapping of code points to the corresponding Chinese content was added to the Chinese locales file. Then translating the Chinese content and inserting a mapping of code points to the translated content in the locales files of the respective languages. When the project was small and the amount of Chinese characters was limited, the cost of manual maintenance was relatively acceptable. However, as the project scale expanded and the number of Chinese characters increased, the cost of manually maintaining locales files rose exponentially. Therefore, an automated i18n tool was needed to meet the i18n requirements of the Karmada dashboard. In the open source community, it was hard to find a ready-to-use i18n tool that perfectly supported the i18n needs of the Karmada dashboard. Therefore, we aimed to develop an automated i18n tool which is based on the perspective of the Karmada dashboard's i18n requirements, to satisfy the specific i18n needs of the Karmada dashboard.
Copy link
Contributor

Choose a reason for hiding this comment

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

increased rapidly


## Motivation

During the development of the Karmada dashboard, early on, we maintained the locales files manually. If new Chinese content was added to the code, it required to replace by the corresponding i18n keys and functions. After that, a mapping of code points to the corresponding Chinese content was added to the Chinese locales file. Then translating the Chinese content and inserting a mapping of code points to the translated content in the locales files of the respective languages. When the project was small and the amount of Chinese characters was limited, the cost of manual maintenance was relatively acceptable. However, as the project scale expanded and the number of Chinese characters increased, the cost of manually maintaining locales files rose exponentially. Therefore, an automated i18n tool was needed to meet the i18n requirements of the Karmada dashboard. In the open source community, it was hard to find a ready-to-use i18n tool that perfectly supported the i18n needs of the Karmada dashboard. Therefore, we aimed to develop an automated i18n tool which is based on the perspective of the Karmada dashboard's i18n requirements, to satisfy the specific i18n needs of the Karmada dashboard.
Copy link
Contributor

Choose a reason for hiding this comment

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

the cost of maintaining locales files in manual way rose exponentially


## Motivation

During the development of the Karmada dashboard, early on, we maintained the locales files manually. If new Chinese content was added to the code, it required to replace by the corresponding i18n keys and functions. After that, a mapping of code points to the corresponding Chinese content was added to the Chinese locales file. Then translating the Chinese content and inserting a mapping of code points to the translated content in the locales files of the respective languages. When the project was small and the amount of Chinese characters was limited, the cost of manual maintenance was relatively acceptable. However, as the project scale expanded and the number of Chinese characters increased, the cost of manually maintaining locales files rose exponentially. Therefore, an automated i18n tool was needed to meet the i18n requirements of the Karmada dashboard. In the open source community, it was hard to find a ready-to-use i18n tool that perfectly supported the i18n needs of the Karmada dashboard. Therefore, we aimed to develop an automated i18n tool which is based on the perspective of the Karmada dashboard's i18n requirements, to satisfy the specific i18n needs of the Karmada dashboard.
Copy link
Contributor

Choose a reason for hiding this comment

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

out-of-the-box


## Proposal

<!--
Copy link
Contributor

Choose a reason for hiding this comment

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

why only Chinese comment here? should it be removed?


1. processAST Function: Responsible for processing the AST, identifying and replacing Chinese strings.
2. generateKey Function: Generates unique keys for use in the i18n JSON file.
3. updateLocales Function: Update Locales files as material for subsequent translation functions.
Copy link
Contributor

Choose a reason for hiding this comment

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

Update locales files

<!--
扫描流程:扫描模块负责接收外部传入的原始文件,返回处理好的AST(Abstract Syntax Tree)树,内部流程如图:
-->
Convert the input files into an AST, traverse the AST to find nodes which containing Chinese characters, calculate the code points corresponding to the Chinese characters and save them in the i18nMap, and save the transformed AST nodes in CNpath. After completing one scan, continue to traverse CNpath, converting the Chinese characters in the corresponding AST nodes into the form of i18n function calls, and generate a new AST tree to return.
Copy link
Contributor

Choose a reason for hiding this comment

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

After the first round of scanning finished,

<!--
代码生成流程:接收扫描模块返回的修改后的AST树,将修改后的AST树转换成原始代码,内部流程如图:
-->
If the original code does not include an import statement for the i18n instance, an appropriate import statement needs to be inserted. This completes the main workflow of code generation. The process of code generation might inadvertently alter statements unrelated to i18n. To address this issue, a prettier process is introduced to style the generated code according to the original coding style, minimizing changes which brought by code-gen. Finally, the newly generated code is written back into the original file.
Copy link
Contributor

Choose a reason for hiding this comment

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

which were introduced by code-gen


## Motivation

During the development of the Karmada dashboard, early on, we maintained the locales files manually. If new Chinese content was added to the code, it required to replace by the corresponding i18n keys and functions. After that, a mapping of code points to the corresponding Chinese content was added to the Chinese locales file. Then translating the Chinese content and inserting a mapping of code points to the translated content in the locales files of the respective languages. When the project was small and the amount of Chinese characters was limited, the cost of manual maintenance was relatively acceptable. However, as the project scale expanded and the number of Chinese characters increased, the cost of manually maintaining locales files rose exponentially. Therefore, an automated i18n tool was needed to meet the i18n requirements of the Karmada dashboard. In the open source community, it was hard to find a ready-to-use i18n tool that perfectly supported the i18n needs of the Karmada dashboard. Therefore, we aimed to develop an automated i18n tool which is based on the perspective of the Karmada dashboard's i18n requirements, to satisfy the specific i18n needs of the Karmada dashboard.
Copy link
Contributor

Choose a reason for hiding this comment

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

was acceptable

#### Story 2
As software developers, they can improve the code for each module. The executable code for each module is stored in the 'src' directory. Developers simply need to open each file to directly modify and enhance it. When they want to develop new tools in the future and need to use these modules, they can directly reference them, avoiding redundant production.
<!--
作为程序开发者,它可以对每个模块的代码进行改进。在scr目录下存放了每个模块的执行代码。开发者只需点开每个文件即可直接对其进行修改和增强。当他们在未来想开发的新的工具,需要用到这些模块时,也可以直接进行引用,避免了重复生产。
Copy link
Contributor

Choose a reason for hiding this comment

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

src

Copy link
Contributor

Choose a reason for hiding this comment

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

image
plz recheck it~

-->

#### Story 1
As a developer of the Karmada dashboard, when introducing new features with a significant amount of new Chinese content, there is an automated tool that can extract, translate, and generate corresponding locale files for this new content with a single click, thereby reducing the maintenance cost of i18n. The community administrator provides the corresponding i18n translation rules for specific descriptions. In automatic translation, you can preferentially use the i18n translation rules provided by the community administrator and combine them with automatic translation to improve the overall effect of i18n translation.
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems that, it's two user-stories?

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 it's same situation to community members.


## Summary

Internationalization (aka i18n) is essential for software that aims to become global. During the development of the Karmada dashboard, we suffered from low efficiency、 easy to make mistakes、lack of engineering due to maintaining i18n translation (aka locales) manually. To solve these issues and meet the i18n needs of the Karmada dashboard project, we developed a out-of-the-box automated i18n tool.
Copy link
Contributor

Choose a reason for hiding this comment

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

here should use an out-of-the-box automated i18n tool, not using a


## Motivation

During the development of the Karmada dashboard, we maintained the locales files manually in the early stages. If new Chinese content was added to the code, we need to replace Chinese content with i18n keys and i18n function. After that, a mapping of code points to the corresponding Chinese content was added to the Chinese locales file. Then translating the Chinese content and inserting a mapping of code points to the translated content in the locales files of the respective languages. When the project was small and the amount of Chinese characters was limited, the cost of manual maintenance was relatively acceptable. However, as the project scale up expanded and the number of Chinese characters increased rapidly, the cost of maintaining locales files in manual way rose exponentially. Therefore, an automated i18n tool was needed to meet the i18n requirements of the Karmada dashboard. In the open source community, it was hard to find a out-of-the-box i18n tool that perfectly supported the i18n needs of the Karmada dashboard. Therefore, we aimed to develop an automated i18n tool which is based on the perspective of the Karmada dashboard's i18n requirements, to satisfy the specific i18n needs of the Karmada dashboard.
Copy link
Contributor

Choose a reason for hiding this comment

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

here need to remove expanded~

#### Story 2
As software developers, they can improve the code for each module. The executable code for each module is stored in the 'src' directory. Developers simply need to open each file to directly modify and enhance it. When they want to develop new tools in the future and need to use these modules, they can directly reference them, avoiding redundant production.
<!--
作为程序开发者,它可以对每个模块的代码进行改进。在scr目录下存放了每个模块的执行代码。开发者只需点开每个文件即可直接对其进行修改和增强。当他们在未来想开发的新的工具,需要用到这些模块时,也可以直接进行引用,避免了重复生产。
Copy link
Contributor

Choose a reason for hiding this comment

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

image
plz recheck it~

@chouchongYHMing chouchongYHMing force-pushed the i18n-tool-proposal branch 2 times, most recently from 8b9bef0 to ceb8d90 Compare September 10, 2024 06:38
Signed-off-by: chouchongYHMing <121396869+chouchongYHMing@users.noreply.github.com>
@warjiang
Copy link
Contributor

/lgtm
/approve

@karmada-bot karmada-bot added the lgtm Indicates that a PR is ready to be merged. label Sep 10, 2024
@karmada-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: warjiang

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@karmada-bot karmada-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 10, 2024
@karmada-bot karmada-bot merged commit 89b733d into karmada-io:main Sep 10, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants