Borrar filtros
Borrar filtros

GUI - switching language

3 visualizaciones (últimos 30 días)
keenN
keenN el 22 de Feb. de 2011
Respondida: Roberto el 26 de Abr. de 2014
Hello, I am working on a GUI with a language selection. I put the language selection in a listbox as strings. My question is, how do I program the GUI to be able to change all the texts in current GUI and all other connected GUIs according to the language selected? I'd really appreciate anyone's help. Thanks!

Respuestas (1)

Roberto
Roberto el 26 de Abr. de 2014
you'll have to store all the 'strings' in a external file, or in the same file but it's going to be huge: here's an idea of how to do it, as simple as 1,2,3:
1. Create a GUI with default text values and tag properties considering previous tags:
f= figure ;
h1 = uicontrol(f,'style','pushbutton','position',[10 10 200 20],...
'tag','txtOne','String','default text') ;
h2 = uicontrol(f,'style','text','position',[10 35 200 20],...
'tag','txtother','String','default text2') ;
2. Create a function to change the 'String' property for all elements
function changeLan(figureHandle,lanIndex)
tags = {'txtOne','txtother'} ;
strs{1} = {'My text', 'Other text'} ;
strs{2} = {'Mi texto', 'otro texto'} ;
for i = 1:length(tags)
handle = findobj(f,'tag',tags{i}) ;
set(handle,'String',strs{lanIndex}{i});
end
end
3. call the function to change the language:
changeLan(f,1);
changeLan(f,2);
Hope it will help you! :)

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by