1. Currently, translation strings are stored in files under the resources/lang directory. In this directory, there should be a corresponding subdirectory for each language supported by the application:
/resources
/lang
/en
validation.php
/en-US
validation.php
2. The previous calling method: return trans(‘online_store_theme_graphql::validation.custom.theme_editor_session.theme_editor_session_id_exists_rule’);
3. Plan to store translation files in JSON format in the resources/lang directory
/resources
/lang
/en
validation.php
/en-US
validation.php
en.json
en-US.json
3. Deliberately differentiate between /en/validation.php and en.json to confirm the priority order. Confirmed that .php has a higher priority than .json. See Figure 1

<?php
return [
'custom' => [
'theme_editor_session' => [
'theme_editor_session_id_exists_rule' => 'The selected :attribute is invalid.',
],
],
'attributes' => [],
];{
"validation.custom.theme_editor_session.theme_editor_session_id_exists_rule": "The selected :attribute is invalid1."
}
4. Delete the PHP-related directories and files
/resources
/lang
en.json
en-US.json
5. Found that the translation is not working properly. See Figure 2

6. Use the App Facade’s getLocale and isLocale methods to determine the current locale
echo App::getLocale();
exit;
{
"error": {},
"text": "en"
}
7. Referenced How to use json translation files using modules? (Translation Strings As Keys): https://github.com/nWidart/laravel-modules/issues/954 . Adjusted registerTranslations() in the service provider, removed the reference to PHP files, and adopted the reference to JSON files.
/**
* Register translations.
*
* @return void
*/
public function registerTranslations()
{
$langPath = resource_path('lang/modules/' . $this->moduleNameLower);
if (is_dir($langPath)) {
$this->loadTranslationsFrom($langPath, $this->moduleNameLower);
$this->loadJsonTranslationsFrom($langPath);
} else {
$this->loadTranslationsFrom(__DIR__ . '/../Resources/lang', $this->moduleNameLower);
$this->loadJsonTranslationsFrom(__DIR__ . '/../Resources/lang');
}
}
/**
* Register translations.
*
* @return void
*/
public function registerTranslations()
{
$langPath = resource_path('lang/modules/' . $this->moduleNameLower);
if (is_dir($langPath)) {
$this->loadJsonTranslationsFrom($langPath);
} else {
$this->loadJsonTranslationsFrom(__DIR__ . '/../Resources/lang');
}
}
8. The translation still does not work properly. Finally decided to abandon this implementation for now.
