MATLAB Answers

kinidi
0

App designer big projects

Asked by kinidi
on 13 Nov 2019 at 12:03
Latest activity Commented on by virup Rao on 20 Nov 2019 at 4:39
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 on 20 Nov 2019 at 4:39
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.

2 Answers

Rik
Answer by Rik
on 14 Nov 2019 at 22:56
Edited by Rik
on 14 Nov 2019 at 23:00
 Accepted Answer

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
on 15 Nov 2019 at 9:54
Comment posted as answer by kinidi:
hello Rik ,
thank you very much for your help, but I think the solution with the dictionary is very complicated,
as I already have all the words and their translation in an excel file, so normally I would not need to download a dictionner
I just need to browse to Excel file
here is the sample file
Rik
on 15 Nov 2019 at 9:59
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
on 16 Nov 2019 at 13:35
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.


Kumar
Answer by Kumar
on 13 Nov 2019 at 13:45

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

kinidi
on 13 Nov 2019 at 21:06
Thank you for this answer,
but the big problem is how to program this push button ,in which ,that every time I change the language, all texts and titles of the interface changing according to the language chosen ,
and this whithe Excel file .
thank you very Much
Kumar
on 14 Nov 2019 at 20:09
"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
on 14 Nov 2019 at 22:03
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.