App designer big projects

3 次查看(过去 30 天)
kinidi
kinidi 2019-11-13
评论: virup Rao 2019-11-20
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
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
Rik 2019-11-14
编辑:Rik 2019-11-14
One possible solution involves two steps:
  1. Load the dictionary
  2. 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
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.
kinidi
kinidi 2019-11-16
thank you verry much for the clarification ,
I think I will keep THE first solution, despite it's too long,
(value = app.LanguageDropdown.Value;
if value == "english"
% do english operations
elseif value == "french"
% do french operations
end)
now I have a great database excel (several table in a single Excel sheet) and I want to use it for calculation in Matlab App designer, my question is how can I get my data from this database (Excel) and use them on Matlab App designer, MY solution is: - I stored these table in Matlab as variable (cell array) , and I want every time I need a data I will go to find these variables. Unfortunately my solution does not work, may be you have an idea? (how to use an excel static database file for calculations in matlab (app designer)
it is attached my Excel tables store forms variable in Matlab
Varia.PNG
thank you for the help

请先登录,再进行评论。

更多回答(1 个)

Ajay Kumar
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
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
kinidi
kinidi 2019-11-14
编辑:Rik 2019-11-14
i thank you for this good answer ,
(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
)).
it's what I have already done , and NOW i want this dropdown
call back such that it gets to the file using uigetfile and reads the file using xlsread.
and I want to open excel immediately after selecting the language in dropdown, and all the words and titles (texte) of my gui doing a traduction
(without coding all the words and texts in the program, I want all the words and all the texts to reside in an Excel file and I would just loop to browse the Excel file and change the words in the interface )
thank you for the help

请先登录,再进行评论。

类别

Help CenterFile 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!

Translated by