Skip to content

Conversation

@ardelato
Copy link
Collaborator

@ardelato ardelato commented Jul 3, 2025

Description

This adds two new Artisan commands to automate translation workflows:

  • translations:manage - Main translation pipeline command that can extract translations from
    Laravel locale files and orchestrate the full translation process via DeepL API
  • translations:deepl - Low-level DeepL API wrapper providing direct translation services,
    language listing, usage monitoring, and API testing capabilities

Key features:

  • Extracts translations from PHP locale files while preserving Laravel placeholders (:name)
  • Handles HTML tags by replacing them with placeholders to allow DeepL to translate text without markup
  • Supports batch processing to respect DeepL API limits and rate limiting
  • Generates properly formatted PHP locale files for target languages in
    specified instance
  • Supports both free and pro DeepL API endpoints

This should make it easier to maintain translations across multiple instances and locales. If manually done, one would need to grab just the values from the locale arrays, remove placeholders and html tags, translate the original text, re-add placeholders and html tags, and then add the new locale array/files to the instance.

CR Notes

I was originally going to just translate the fixitclinic locale files but it turned out that the base locale files were not fully translated. As such, we would have had a mix of translated and non-translated content on the website.

To resolve this, and simplify future translations, I created these two new commands that would interact with the DeepL api and auto-translate the content for us.

SnagitHelper2023 2025-07-03 08 34 13

qa_req 0

Before After
SnagitHelper2023 2025-07-03 08 57 48 SnagitHelper2023 2025-07-03 08 57 14

ardelato added 6 commits July 3, 2025 08:21
Add two new Artisan commands to automate translation workflows:

- translations:manage - Main translation pipeline command that can extract translations from
  Laravel locale files and orchestrate the full translation process via DeepL API
- translations:deepl - Low-level DeepL API wrapper providing direct translation services,
  language listing, usage monitoring, and API testing capabilities

Key features:
- Extracts translations from PHP locale files while preserving Laravel placeholders (:name)
- Handles HTML tags by replacing them with placeholders to allow DeepL to translate text without markup
- Supports batch processing to respect DeepL API limits and rate limiting
- Generates properly formatted PHP locale files for target languages in
specified instance
- Supports both free and pro DeepL API endpoints

This should make it easier to maintain translations across multiple
instances and locales. If manually done, one would need to grab just the
values from the locale arrays, remove placeholders and html tags, translate
the orginal text, re-add placeholders and html tags, and then add the new
locale array/files to the instance.
DeepL does not support Belgian variants so we will be disabling them
to make things simpler. If we need to support them in the future, we
will need to manually translate the content for fr-BE and nl-BE.
The `no` locale had some Dutch content which meant it was the `nl` locale.
I further confirmed this by validating there was no `no` locale defined
in the laravellocalization.php config file. Let's rename the folder
to `nl`.
I ran translations:manage for all core locales: de, es, fr, it, and nl.
The `ne` locale is for Nepali which is not supported by DeepL nor is it
enabled in the laravellocalization.php config file. As such, we will
be skipping it.
Copy link
Member

@mlahargou mlahargou left a comment

Choose a reason for hiding this comment

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

CR 📱

@ardelato ardelato merged commit 4c725c5 into hermes Jul 9, 2025
@ardelato ardelato deleted the feat--add-deepl-command branch July 9, 2025 22:14
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.

3 participants