App designer big projects
3 ビュー (過去 30 日間)
古いコメントを表示
hello everyone, I hope you are fine,
So,I created a Great GUI With Matlab App Designer, in which I can set a product, so my interface contains 3 sub interface, and I created a drop down that contains 4 languages, and every time I choose a language, all the most of interface changes depending on the language chosen, ('français , English , spanish , Russian),
and I have coded all the words on the program, what did a long programe!.
and now I want to know if there is a way to do this by browsing an excel file where there is all the languages and all the words, and how to proceed to read an excel file with App designer?
thank you by advance.
1 件のコメント
virup Rao
2019 年 11 月 20 日
Kindi,
I do have the similiar requirement and i have been working on it for sometime.
I could not get the proper Solution
Is it really need to translate every text box/button/title labels before hand?
I am looking for some simpler solution where if i select the lanaguage based on some property changes all the labels should change to their respecitve lanaguages.
Is this possible?
If not, I will also do as you have created excel file and read that excel file.
Could please share your source code if possible for me to refer the translation sequence?
Thank You in advance.
採用された回答
Rik
2019 年 11 月 14 日
編集済み: Rik
2019 年 11 月 14 日
One possible solution involves two steps:
- Load the dictionary
- Reset the texts that are visible with the updated dictionary
You can see this approach being used in my FEX submissions (link and link). Those functions require a restart, but if you keep a list of handles of objects you need to replace, you can do a live update.
The main idea is to keep something like the dictionary below, and use that to (re)set your text. This example has the texts in the function itself, but you can also put these things in an excel file and read the list of string IDs with the contents per language.
%in your dictionary function:
lang=1;
dict=struct;
tmp={'open file','ouvrir fichier'}
dict.open_file=tmp{lang};
tmp={'exit','fermer'};
dict.exit=tmp{lang};
%%% now dict contains strings you can use to update your buttons
%in your dictionary selection function:
dict=get_dict(lang);
app.open_button.String=dict.open_file;
app.close_button.String=dict.exit;
%much better idea: keep a list of objects with their dict field name, instead of hard-coding this
I never use AppDesigner, so I'm not sure the syntax of the last part works
3 件のコメント
Rik
2019 年 11 月 15 日
The only thing you need to do is adding a key to your Excel file. Most programs that have multiple languages work like this: every text box/button/title gets a label. Then the appropriate text is put in a dictionary file where there is an entry for every language-key combination. If you prefer to use Excel as your dictionary file, the only thing you need to do is add a column with labels and write a parser function that returns a dict struct. Then you can use the system I described to update all labels.
その他の回答 (1 件)
Ajay Kumar
2019 年 11 月 13 日
Yes, you can read an excel sheet and get the words. Simply create a push button in the GUI, in the pushbutton callback, write the logic to read excel sheet from the directory.
doc uigetfile
doc xlsread
3 件のコメント
Ajay Kumar
2019 年 11 月 14 日
"big project", "big problem"
Any big thing can be broken into pieces and here the logic is no different.
"I created a Great GUI With Matlab App Designer"
As I suggested before, start from the scratch. Into your great GUI, first add the push button. Then implement the push button call back such that it gets to the file using uigetfile and reads the file using xlsread.
Otherwise if you don't want any pushbutton to read file and want to open excel immediately after selecting the language in dropdown, write the above logic in dropdown callback and using if loops do the required operations.
for example:
value = app.LanguageDropdown.Value;
if value == "english"
% do english operations
elseif value == "french"
% do french operations
end
参考
カテゴリ
Help Center および File Exchange で Develop Apps Using App Designer についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!