Closed zhaiyuxin103 closed 5 months ago
@zhaiyuxin103 Could you elaborate your question? I don't understand what you are trying to ask.
@zhaiyuxin103你能详细说明你的问题吗?我不明白你想问什么。
Sorry, I didn't make it clear My English is not very good First edit a group key in Filament Dashboard How to use it in the page later? Although the language in the database has been changed However, the return values of the trans and __ functions remain unchanged. Or am I misunderstanding the function of the expansion pack?
No problem, thanks for the elaboration.
After you edited a language key using the translation manager on the filament dashboard. For example, you've either changed a value or added a new language for that language key.
How to use it
In case you've just edited the language key, the change should be visible on the dashboard. But if you don't see any change, you'll need to run php artisan cache:clear
.
If you have added a new translation for the language key, you'll need to switch languages of your dashboard using the language switcher, and then you'll see the changes you've made in that specific language reflect on the dashboard.
If it's still not clear, could you maybe share a screen recording with me of what you are trying to do? This may help me assist you better.
Changes can be seen on the dashboard
What I want to know is why the return value of the trans
and __
functions is still the text in the lang language file, rather than the value that I modified and stored in the database?
I executed php artisan cache:clear
and php artisan optimize:clear
Does the language key of the language you've translated exist in the language_line table in you database?
and could you possible share your config/translation-manager.php
The language key of the language I translated exists in the language_line of the database.
Is it language_lines or language_line?
Below is my config/translation-manager.php
<?php
return [
/*
|--------------------------------------------------------------------------
| Available Application Locales
|--------------------------------------------------------------------------
|
| The available application locales that can be used.
| For flag codes, please refer to https://flagicons.lipis.dev/ (e.g. nl for Netherlands).
|
*/
'available_locales' => [
['code' => 'ja', 'name' => '日本語'],
['code' => 'zh_CN', 'name' => '简体中文'],
],
/*
|--------------------------------------------------------------------------
| Disable key and group editing
|--------------------------------------------------------------------------
|
| Whether editing the key and group values is disabled. By default, this is true
| because these values are automatically added by the synchronization process.
|
*/
'disable_key_and_group_editing' => true,
/*
|--------------------------------------------------------------------------
| Language Switcher
|--------------------------------------------------------------------------
|
| Enable the language switcher feature in the Filament top bar.
|
*/
'language_switcher' => true,
/*
|--------------------------------------------------------------------------
|
| Determines the render hook for the language switcher.
| Available render hooks: https://filamentphp.com/docs/3.x/support/render-hooks#available-render-hooks
|
*/
'language_switcher_render_hook' => 'panels::user-menu.before',
/*
|--------------------------------------------------------------------------
| Navigation Group
|--------------------------------------------------------------------------
|
| 'navigation_group' is the group in which the translation manager is displayed.
| For instance, it could be set to 'Admin'.
|
| 'navigation_group_translation_key' is used for a translation key.
| For example, it could be set to 'navigation.manageSettings'.
| If this key is filled, it will override navigation_group settings.
| Set it to null if you do not want to use it.
|
*/
'navigation_group_translation_key' => null,
'navigation_group' => '翻訳管理',
/*
|--------------------------------------------------------------------------
| Navigation Icon
|--------------------------------------------------------------------------
|
| The navigation icon to use. Set `false` to disable the icon
| or specify a custom icon
|
*/
'navigation_icon' => 'heroicon-o-globe-alt',
/*
|--------------------------------------------------------------------------
| Quick-Translate Navigation Registration
|--------------------------------------------------------------------------
|
| Whether to register the quick-translate page in navigation.
|
*/
'quick_translate_navigation_registration' => false,
/*
|--------------------------------------------------------------------------
| Don't Register Navigation On Panels
|--------------------------------------------------------------------------
|
| Array of panel id's which not to register navigation on.
| i.e. => ['guest', 'team1']
|
*/
'dont_register_navigation_on_panel_ids' => [],
/*
|--------------------------------------------------------------------------
| Flags or Initials
|--------------------------------------------------------------------------
|
| Control whether to express locales using international flags, or through locale initial letters if disabled in the language switcher.
|
*/
'show_flags' => false,
/*
|--------------------------------------------------------------------------
| Prepend directory path to group name
|--------------------------------------------------------------------------
|
| Control whether to append the directory path to the group name.
| ex. If the translation file for settings is in directory lang/en/settings/user.php
| The group name will be settings/user
|
*/
'prepend_directory_path_to_group_name' => false,
];
Thank you, I'll try to replicate it in my environment. I'll get back to you soon.
Thank you very much!
I've been looking, but how exactly do you use the __
or trans()
?
Do you call it like this __('labels.images')
Yes, I generally use __
in template files and trans
in php files.
My lang files and localization functions are used as follows:
This is a tough one. What do you use for your CACHE_DRIVER
in your .env file
I'm using Laravel 11 version There is no CACHE_DRIVER in env Should it be CACHE_STORE? My value is: redis
Could you maybe try to use for the CHACHE_STORE=file
or CACHE_STORE=array
and after your change run php artisan optimize:clear
. I'm curious if anything changes
I'm encountering a similar question about using this package. After editing a string in the Dashboard, it updates only in the database, not in the actual .php file inside the lang folder. I use Vue.js for my frontend, and the suggestions given didn't help to answer my question. Do I need to fetch the translated text directly from the database?
@DonatasIk this package does not make any changes to your file. It only adds all the newly created translations in the database. And it will be cached so retrieving translations is done quickly.
Need to query the database?