App designer big projects
13 次查看(过去 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 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!