Skip to content

Commit

Permalink
Improve translate docs (#264)
Browse files Browse the repository at this point in the history
* chore: skip code blocks

* chore: skip code blocks

* chore: skip code blocks

* chore: skip code blocks

* chore: skip code blocks

* chore: add assets folder

* fix

* fix: branch name
  • Loading branch information
fproldan authored Jul 24, 2024
1 parent 94d8004 commit 95eabab
Show file tree
Hide file tree
Showing 13 changed files with 35 additions and 9 deletions.
2 changes: 1 addition & 1 deletion docs/version-14/en/achgeneration.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ Other fields available to help configure your ACH generation include:

The 'Custom Post Processing Hook' is a read-only field and not intended to be set by non-technical users. The RBC example noted above can be set by entering the following into the browser console: `cur_frm.set_value('custom_post_processing_hook','check_run.test_setup.example_post_processing_hook')`. Provide the dotted path to your function with a signature matching that of the example.

![Example ACH file data with properly-formatted header and batch entries.](./assets/ACHFile.png)
![Example ACH file data with properly-formatted header and batch entries.](./assets/ACHFile.png)
1 change: 1 addition & 0 deletions docs/version-14/en/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,4 @@ The `Bank` and `Bank Account` fields are retrieved by the system to facilitate p
Similarly, the `Employee` doctype includes new `Mode of Payment`, `Bank`, and `Bank Account` fields in the "Salary Details" section. The `Mode of Payment` value will show in a Check Run, and the system uses the `Bank` and `Bank Account` values for electronic payments.

![Employee doctype detail showing the expanded Salary Details section with new fields for Mode of Payment, Bank, and Bank Account.](./assets/ConfigEmployee.png)

2 changes: 2 additions & 0 deletions docs/version-14/en/exampledata.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ It's recommended to install the demo data into its own site to avoid potential i

With `bench start` running in the background, run the following command to install the demo data:


```shell
bench execute 'check_run.test_setup.before_test'
# to reinstall from scratch and setup test data
bench reinstall --yes --admin-password admin --mariadb-root-password admin && bench execute 'check_run.tests.setup.before_test'
```

Refer to the [installation guide](./installationguide.md) for detailed instructions for how to set up a bench, a new site, and installing ERPNext and the Check Run application.

1 change: 1 addition & 0 deletions docs/version-14/en/exampleprint.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ The example print format included with this application can be found in the Prin
Additional resources:

- [ERPNext print format documentation](https://docs.erpnext.com/docs/v14/user/manual/en/customize-erpnext/print-format)

1 change: 1 addition & 0 deletions docs/version-14/en/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,4 @@ Follow the links below for more information about Check Run's features:
- [Translations](./translations.md)

[^1]: [ERPNext](https://erpnext.com/) is an open-sourced Enterprise Resource Planning (ERP) software that provides a wide range of business management functionality. Its core features include support for accounting, inventory, manufacturing, customer relationship management (CRM), distribution, and retail.

1 change: 1 addition & 0 deletions docs/version-14/en/installationguide.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,4 @@ Optional: install a [demo Company and its data](./exampledata.md) to test the Ch
```shell
bench execute 'check_run.tests.setup.before_test'
```

1 change: 1 addition & 0 deletions docs/version-14/en/payment_entry.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ This setting on Bank Account automatically fetches the Bank Account into the Pay
Check Run takes the opinion that there is no scenario where it it appropriate to cut a check without providing a reference document. Payment References has been customized to be required unless the Payment Entry is of type 'Internal Transfer'.

Since the Purchase Invoices displayed in a Check Run are automatically split by their Payment Terms (if the invoice has a defined Payment Schedule), it's important that a Payment Entry for a portion of an invoice made outside of a Check Run properly links a Payment Reference to a Payment Term. Check Run includes a validation that attempts to fill this in, and warns the user to review. For more information, refer to the "Considerations for Purchase Invoices with Payment Schedules" section on the [Settings page](./settings.md).

2 changes: 2 additions & 0 deletions docs/version-14/en/permissions.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ Only one draft Check Run is allowed per payable/bank account combination. This i

## Role Permissions
Out of the box, Check Run is permissioned the same as Payment Entry. For most small organizations this may be fine, but larger organizations with document approval policies and a desire to limit persons with access to printed checks will likely want to implement additional policies. Check Run print and ACH generation policies are based on permissions for Payment Entry, not on Check Run itself.


2 changes: 1 addition & 1 deletion docs/version-14/en/positivepay.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ The Check Run application includes a new Positive Pay report. This report genera

To access the report, type "Report Positive Pay" into the AwesomeBar. Enter the bank account, start date, and end date. The report will display a table showing the check date, check number, and party name for all checks against the bank account within the specified time period.

![Screen shot of an example Positive Pay report showing columns for Check Date, Check Number, and Party Name.](./assets/PositivePayReport.png)
![Screen shot of an example Positive Pay report showing columns for Check Date, Check Number, and Party Name.](./assets/PositivePayReport.png)
2 changes: 1 addition & 1 deletion docs/version-14/en/renderpdfsequence.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

After a Check Run has been submitted, it will begin rendering the Checks it needs to print. Even on powerful systems it can take several minutes to render checks. The Check Run creates a new Folder in the File Manager for PDFs. These will be linked to the Check Run but removed when the user confirms they have printed correctly.

![Screen shot showing options to "Confirm Print" if the Checks printed properly, or "Re-Print Checks" if not.](./assets/PrintConfirmation.png)
![Screen shot showing options to "Confirm Print" if the Checks printed properly, or "Re-Print Checks" if not.](./assets/PrintConfirmation.png)
1 change: 1 addition & 0 deletions docs/version-14/en/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,4 @@ Check Run leverages the built-in ERPNext mechanism that automatically updates an
2. If you're creating a Payment Entry outside of a Check Run that's for a portion of an invoice (to satisfy a Payment Term), there's a validation in place to check for and link to the most recent outstanding Payment Term. If the Payment Term field in the Payment References table is left blank, it attempts to fill in the field and warn the user to review. If the Payment Entry covers multiple Payment Terms, there should be a row for each portion of the payment with a link to its respective Payment Term.

![Screen shot of the form dialog when a row in the Payment References table is edited. The Payment Term field shows a value of "Rental Installment 3" to link the allocated amount of the payment to the appropriate term in the invoice's Payment Schedule.](./assets/PaymentEntryPaymentTerm.png)

1 change: 1 addition & 0 deletions docs/version-14/en/translations.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
The Check Run application currently offers a Canadian regionalization. To utilize this feature, Canadian users should select the "English (United Kingdom)" (`en-GB`) language option under their user settings.

Contributions for other translations are welcome.

27 changes: 21 additions & 6 deletions translate_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,26 @@ def get_pull_request_number():
return int(match.group(1)) if match else None


def translate_file(source_file, target_file, target_language, translate_client):
def extract_code_blocks(text):
code_blocks = re.findall(r"```.*?```", text, re.DOTALL)
text_without_code = re.sub(r"```.*?```", "CODE_BLOCK_PLACEHOLDER", text, flags=re.DOTALL)
return text_without_code, code_blocks


def reintegrate_code_blocks(translated_text, code_blocks):
for code in code_blocks:
translated_text = translated_text.replace("CODE_BLOCK_PLACEHOLDER", code, 1)
return translated_text


def translate_file(source_content, target_file, target_language, translate_client):
text_without_code, code_blocks = extract_code_blocks(source_content)
translation = translate_client.translate(
source_file, target_language=target_language, format_="text"
text_without_code, target_language=target_language, format_="text"
)
final_text = reintegrate_code_blocks(translation["translatedText"], code_blocks)
with open(target_file, "w", encoding="utf-8") as f:
f.write(translation["translatedText"])
f.write(final_text)


def translate_md_files():
Expand Down Expand Up @@ -79,13 +93,14 @@ def translate_md_files():
for target_language in target_languages:
for filename, modified_file in modified_files.items():
if filename.startswith(f"docs/{version}/en") and filename.endswith(".md"):
source_file = modified_file
target_folder = f"docs/{version}/{target_language}"
target_file = os.path.join(target_folder, os.path.basename(filename))
if not os.path.exists(target_folder):
os.makedirs(target_folder)
futures.append(
executor.submit(translate_file, source_file, target_file, target_language, translate_client)
executor.submit(
translate_file, modified_file, target_file, target_language, translate_client
)
)

for future in as_completed(futures):
Expand All @@ -97,7 +112,7 @@ def translate_md_files():
for version in version_folders:
for target_language in target_languages:
target_folder = f"docs/{version}/{target_language}"
branch_name = f"translate-{target_language}"
branch_name = f"translate-{target_language}-{pull_request_number}"
repo.git.checkout(base_branch)
repo.git.checkout("-b", branch_name)
repo.index.add([target_folder])
Expand Down

0 comments on commit 95eabab

Please sign in to comment.