homepage Welcome to WebmasterWorld Guest from 174.129.76.87
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
Substructures and detecting if in structure and its values
ocon

5+ Year Member



 
Msg#: 4504971 posted 4:01 am on Oct 7, 2012 (gmt 0)

I'm trying to create structure of various words and phrases in different languages. JavaScript isn't my strong suite, but something like:

var languages = {
"en":{
"load":"Loading",
"next":"Next",
"prev":"Previous"},
es:{
"load":"Carga",
"next":"Próximo",
"prev":"Anterior"},
pt:{
"load":"Carregamento",
"next":"Próximo",
"prev":"Anterior"}};

From this, or whatever may be a more appropriate structure, what I need to do is to be able to detect if a language is in the structure and what a given word or phrase is.

language.indexOf("en");
language.indexOf("de");

selectedLang = "es";
language.selectedLang.load;
language.selectedLang.next;

I'm not sure how best to persue this and would appreciate any advice. Thanks.

 

daveVk

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 4504971 posted 6:54 am on Oct 7, 2012 (gmt 0)

example

if ( languages[selectedLang] !== undefined ) { // have language
loadString = languages[selectedLang].load;
}

Fotiman

WebmasterWorld Senior Member fotiman us a WebmasterWorld Top Contributor of All Time 5+ Year Member



 
Msg#: 4504971 posted 12:52 pm on Oct 7, 2012 (gmt 0)

You might consider using the YUI Internationalization utility for this.
[yuilibrary.com...]

ocon

5+ Year Member



 
Msg#: 4504971 posted 1:17 am on Oct 8, 2012 (gmt 0)

Thanks Dave, that was exactly what I needed.

Fotiman, I'll look into that.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved