App designer big projects

3 views (last 30 days)
kinidi
kinidi on 13 Nov 2019
Commented: virup Rao on 20 Nov 2019
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 Comment
virup Rao
virup Rao on 20 Nov 2019
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.

Sign in to comment.

Accepted Answer

Rik
Rik on 14 Nov 2019
Edited: Rik on 14 Nov 2019
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 Comments
Rik
Rik on 15 Nov 2019
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 on 16 Nov 2019
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

Sign in to comment.

More Answers (1)

Ajay Kumar
Ajay Kumar on 13 Nov 2019
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 Comments
Ajay Kumar
Ajay Kumar on 14 Nov 2019
"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 on 14 Nov 2019
Edited: Rik on 14 Nov 2019
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

Sign in to comment.

Categories

Find more on Develop Apps Using App Designer in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!