Multiple language on custom tab

3 views (last 30 days)
Suraj
Suraj on 29 May 2024
Answered: Jaynik on 27 Jun 2024
I have created my own Custom tab using Json files i have file Structure as
resources >> sl_toolstrip_plugins.json
>>json >> customTab.json
>> customTab_actions.json
>>arasTab_popups.json
from this structure i am loading my custom tab but when i change language of matlab all other tabs change language except custom tab.
how can i add Json of that language or how can i load my custom tab in that language. . . .?
how can i change language of my custom tab according to matlab language ...?

Answers (1)

Jaynik
Jaynik on 27 Jun 2024
Hi Suraj,
One workaround is to create a JSON file for each language you want to support. Create the JSON with translated strings for that language. The structure should match the previously created customTab.json. Once all the JSON files are ready, in your sl_toolstrip_plugins.json, add a new property for each supported language. The value of each property will be the path to the corresponding file. Following is a sample example of the json file:
{
"en_US": "path/to/customTab_en_US.json",
"fr": "path/to/customTab_fr.json"
...
}
When MATLAB starts, you need to load the appropriate file based on the current language setting. You can get the current language and then use the returned language code to select the appropriate file from your sl_toolstrip_plugins.json file. This can be done with the following sample script:
currentLanguage = get(0,'Language');
% Load the appropriate file
if strcmp(currentLanguage, 'en_US')
customTabFile = 'path/to/customTab_en_US.json';
elseif strcmp(currentLanguage, 'fr')
customTabFile = 'path/to/customTab_fr.json';
else
error('Unsupported language');
end
% Load the tab using your custom function and the customTabFile variable
This is a high-level approach and the exact implementation can vary depending on the specifics of your project and the version of MATLAB you are using.

Products


Release

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!