Skip to content

docs: translate to Japanese package-structure-code.md #444

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

Merged
merged 13 commits into from
Apr 16, 2025
Merged

Conversation

tkoyama010
Copy link
Member

@tkoyama010 tkoyama010 commented Feb 15, 2025

ref #352

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
@tkoyama010
Copy link
Member Author

pre-commit.ci autofix

@tkoyama010
Copy link
Member Author

I will merge po file using

def merge_po_files(file_a, file_b, output_file):
    with open(file_a, 'r', encoding='utf-8') as fa, open(file_b, 'r', encoding='utf-8') as fb:
        lines_a = fa.readlines()
        lines_b = fb.readlines()
    
    merged_lines = []
    b_index = 0
    use_a = True  # True for msgid, False for msgstr
    
    for line in lines_a:
        if line.startswith("msgid"):
            use_a = True
        elif line.startswith("msgstr"):
            use_a = False
            while b_index < len(lines_b) and not lines_b[b_index].startswith("msgstr"):
                b_index += 1
        
        if use_a:
            merged_lines.append(line)
        else:
            if b_index < len(lines_b):
                merged_lines.append(lines_b[b_index])
                b_index += 1
            else:
                merged_lines.append(line)  # Fallback measure
    
    with open(output_file, 'w', encoding='utf-8') as fo:
        fo.writelines(merged_lines)
    
    print(f"Merged file saved as {output_file}")

# Example usage
merge_po_files("a.po", "b.po", "merged.po")

@flpm
Copy link
Member

flpm commented Feb 15, 2025

When you update the Japanese translation files using the session in nox the po files will be automatically merged with new changes from the original, without losing the current work.

Is there an issue that is causing you to need to do that manually?

If there is, although it's rare, you can use the gettext module in the standard library, it has functionality to read, write, and merge po files.

@tkoyama010
Copy link
Member Author

Thanks a lot! I'm a bit worried that if we do it that way, the translation might not keep up with changes in the original text. Could you tell me more about the process you're thinking of?

@flpm
Copy link
Member

flpm commented Feb 17, 2025

Sure. The gettext process was designed with the understanding that text will evolve and translations have to evolve too without redoing the work that was already done.

If you run the update-language session in the nox file (line 166) passing the ja language code:

nox -s update-language -- ja

Nox will use sphinx gettext builder and the sphinx-intl tool to update the Japanese translation files with the latest changes to the English version.

The process is aware of the existing translation work and will merge the new English changes to the current Japanese PO files, preserving the current translations.

You will see that after the translations will still be there (you can run the command to generate stats)

If an entry that was already translated has minor changes, the entry is flagged as fuzzy (the fuzzy keyword appears in the PO file) to indicate that a translator should take a look to see if the translation still applies.

If an entry changes significantly (for example if the section is rewritten) it will be added as a new entry and require new translation. But even in this case the process will not deleted previously translated even if they are now orphans (no longer needed because they don't exist anymore in the English document). That cleanup has been done by hand, in order to avoid losing work already done.

If an entry is new, for example there is a new section added to the guide, they will appear as new entries.

@flpm
Copy link
Member

flpm commented Feb 17, 2025

The run stats on the Japanese translation you can run

sphinx-intl stat -l ja

@tkoyama010
Copy link
Member Author

It works! I'm impressed this!! Since other files have been updated, I will split the Pull Request for them!

@tkoyama010
Copy link
Member Author

pre-commit.ci autofix

@tkoyama010
Copy link
Member Author

@all-contributors please add @flpm for question

Copy link
Contributor

@tkoyama010

I've put up a pull request to add @flpm! 🎉

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
@tkoyama010 tkoyama010 marked this pull request as ready for review April 15, 2025 15:10
@tkoyama010
Copy link
Member Author

@flpm This is ready to go. Thanks for your attention!

Copy link
Member

@flpm flpm left a comment

Choose a reason for hiding this comment

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

LGTM, the translation builds without issues

@flpm flpm merged commit 450cd2c into main Apr 16, 2025
3 of 4 checks passed
@flpm flpm deleted the tkoyama010-patch-1 branch April 16, 2025 03:00
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.

None yet

2 participants