SlideShare ist ein Scribd-Unternehmen logo
1 von 13
That’s a nice UI, but have you internationalized your JavaScript Lovemore Nalube Developer University of Cape Town 17 June 2010
Overview Evil ‘n’ Good code Difficulties of i18n-sing JS Why Sakai's needs are unique RESTful access to a Sakai Message bundle DEMO: Course Evaluations and the SMS Credits Transfer tool 2 11th Sakai Conference - June 15-17, 2010
Sample nasty code Common evil case: Good case: var response = xhr.status; alert("You have an error caused by" + response); var response = xhr.status; alert(messageLocator.getString( “ui.site.error”, response); 3 11th Sakai Conference - June 15-17, 2010
Difficulties of i18n-sing JS Cannot rely on browser locale Most users are unaware of the presence of this browser setting JS alone cannot get Sakai Preferences locale setting Do we have to re-create message bundles? Inconsistencies, more effort, harder to maintain navigator.language /* Mozilla */|| navigator.userLanguage /* IE */  4 11th Sakai Conference - June 15-17, 2010
Why Sakai's needs are different 2 stages of language customization: User preference Server configuration Sakai’s own locale lookup is used in many tools Extend this ability to client side tools Date formats vary 5 11th Sakai Conference - June 15-17, 2010
Fun stuff Steps to follow 11th Sakai Conference - June 15-17, 2010 6
Step 1: RESTful access to a Sakai Message bundle Tool level Entity Provider creates a fixed URI for getting a message bundle In a webapp, make a provider class: ResourceLoader resourceLoader =  new ResourceLoader(MESSAGES_BUNDLE_DIR);  // eg. where  MESSAGES_BUNDLE_DIR =  	"org.sakaiproject.evaluation.tool.bundle.messages";              *** NEEDS TO BE A FOLDER! return the key-value equivalents of resourceLoader.entrySet().iterator(); in (for example) HashMap 7 11th Sakai Conference - June 15-17, 2010
Step 2: RESTful access to a Sakai Message bundle POM modifications creates a fixed URI for getting a message bundle Depend on Entity Broker: 8 11th Sakai Conference - June 15-17, 2010
Step 3: RESTful access to a Sakai Message bundle Call Ajax file at JS doc ready:        $.ajax({            url: “/direct/evals-resources/bundle.json”,            global: false,            cache: true,            dataType : "json",            success: function(messageBundleJSON){                messageBundle = messageBundleJSON.data;            }        });  9 11th Sakai Conference - June 15-17, 2010
Step 4: RESTful access to a Sakai Message bundle Start using: var removalString =  fluid.messageLocator( messageBundle )(["administrate.general.enable.response.removal"]);    *** For values with variable replacers like {0}   	as in removeitem.removed.user.message: "Item ({0}) has been removed", // Decoding the key "removeitem.removed.user.message".  //RESULT  removalString = "Item (3) has been removed" var removalString = 	fluid.messageLocator( messageBundle )(["removeitem.removed.user.message"], 3 ); 10 11th Sakai Conference - June 15-17, 2010
Step 4.5: RESTful access to a Sakai Message bundle Simpler way to use: Get a language string like this: //retrieve the message strings for key         messageLocator: function(key, params){             return fluid.messageLocator( messageBundle )([key], params);                     }, var alertError = evalTemplateUtils.messageLocator("evalsettings.email.sent.from", 	helpEmail.toLowerCase())); //if helpEmail.toLowerCase() = help@sakaiproject.org //prints: All emails will be sent from help@sakaiproject.org 11 11th Sakai Conference - June 15-17, 2010
Course Evaluations SMS Credits Transfer Demo 11th Sakai Conference - June 15-17, 2010 12
More info. http://blogs.uct.ac.za/blog/lovemores-world/2009/09/28/consuming-a-sakai-java-messages-resource-bundle-in-javascript-with-fluid-i8n SMS code: https://source.sakaiproject.org/contrib//sms/sms/trunk/user-tool/

Weitere ähnliche Inhalte

Ähnlich wie That’s a nice UI, but have you internationalized your Javascript?

Jwebsocketmobiletechcon2010en 100912071225 Phpapp01
Jwebsocketmobiletechcon2010en 100912071225 Phpapp01Jwebsocketmobiletechcon2010en 100912071225 Phpapp01
Jwebsocketmobiletechcon2010en 100912071225 Phpapp01purans
 
MeasureCamp IX (London) - 10 JavaScript Concepts for web analysts
MeasureCamp IX (London) - 10 JavaScript Concepts for web analystsMeasureCamp IX (London) - 10 JavaScript Concepts for web analysts
MeasureCamp IX (London) - 10 JavaScript Concepts for web analystsSimo Ahava
 
Jakarta EE and MicroProfile Tech Talk
Jakarta EE and MicroProfile Tech TalkJakarta EE and MicroProfile Tech Talk
Jakarta EE and MicroProfile Tech TalkJosh Juneau
 
Bytecode manipulation with Javassist and ASM
Bytecode manipulation with Javassist and ASMBytecode manipulation with Javassist and ASM
Bytecode manipulation with Javassist and ASMashleypuls
 
Java Technology
Java TechnologyJava Technology
Java Technologyifnu bima
 
CTS Conference Web 2.0 Tutorial Part 2
CTS Conference Web 2.0 Tutorial Part 2CTS Conference Web 2.0 Tutorial Part 2
CTS Conference Web 2.0 Tutorial Part 2Geoffrey Fox
 
Using OSGi in Nakamura
Using OSGi in NakamuraUsing OSGi in Nakamura
Using OSGi in NakamuraCarl Hall
 
Using Sakai with Multiple Locales
Using Sakai with Multiple LocalesUsing Sakai with Multiple Locales
Using Sakai with Multiple Localesballsy333
 
Mobile Device APIs
Mobile Device APIsMobile Device APIs
Mobile Device APIsJames Pearce
 
OSGi Community Event 2010 - Enterprise OSGi in WebSphere and Apache Aries
OSGi Community Event 2010 - Enterprise OSGi in WebSphere and Apache AriesOSGi Community Event 2010 - Enterprise OSGi in WebSphere and Apache Aries
OSGi Community Event 2010 - Enterprise OSGi in WebSphere and Apache Ariesmfrancis
 
BarCamp KL H20 Open Social Hackathon
BarCamp KL H20 Open Social HackathonBarCamp KL H20 Open Social Hackathon
BarCamp KL H20 Open Social Hackathonmarvin337
 
Implementing Web Services In Java
Implementing Web Services In JavaImplementing Web Services In Java
Implementing Web Services In JavaEdureka!
 
Java EE 7 Platform: Boosting Productivity and Embracing HTML5 - Arun Gupta (R...
Java EE 7 Platform: Boosting Productivity and Embracing HTML5 - Arun Gupta (R...Java EE 7 Platform: Boosting Productivity and Embracing HTML5 - Arun Gupta (R...
Java EE 7 Platform: Boosting Productivity and Embracing HTML5 - Arun Gupta (R...jaxLondonConference
 
Java EE 7: Boosting Productivity and Embracing HTML5
Java EE 7: Boosting Productivity and Embracing HTML5Java EE 7: Boosting Productivity and Embracing HTML5
Java EE 7: Boosting Productivity and Embracing HTML5Arun Gupta
 
Timings API: Performance Assertion during the functional testing
 Timings API: Performance Assertion during the functional testing Timings API: Performance Assertion during the functional testing
Timings API: Performance Assertion during the functional testingPetrosPlakogiannis
 
Easing offline web application development with GWT
Easing offline web application development with GWTEasing offline web application development with GWT
Easing offline web application development with GWTArnaud Tournier
 
Micronaut Http Client
Micronaut Http ClientMicronaut Http Client
Micronaut Http ClientJames Kleeh
 
EJB et WS (Montreal JUG - 12 mai 2011)
EJB et WS (Montreal JUG - 12 mai 2011)EJB et WS (Montreal JUG - 12 mai 2011)
EJB et WS (Montreal JUG - 12 mai 2011)Montreal JUG
 
From Ruby to Node.js
From Ruby to Node.jsFrom Ruby to Node.js
From Ruby to Node.jsjubilem
 

Ähnlich wie That’s a nice UI, but have you internationalized your Javascript? (20)

Jwebsocketmobiletechcon2010en 100912071225 Phpapp01
Jwebsocketmobiletechcon2010en 100912071225 Phpapp01Jwebsocketmobiletechcon2010en 100912071225 Phpapp01
Jwebsocketmobiletechcon2010en 100912071225 Phpapp01
 
jWebSocket MobileTechCon 2010 - WebSockets on Android, Symbian and BlackBerry
jWebSocket MobileTechCon 2010 - WebSockets on Android, Symbian and BlackBerryjWebSocket MobileTechCon 2010 - WebSockets on Android, Symbian and BlackBerry
jWebSocket MobileTechCon 2010 - WebSockets on Android, Symbian and BlackBerry
 
MeasureCamp IX (London) - 10 JavaScript Concepts for web analysts
MeasureCamp IX (London) - 10 JavaScript Concepts for web analystsMeasureCamp IX (London) - 10 JavaScript Concepts for web analysts
MeasureCamp IX (London) - 10 JavaScript Concepts for web analysts
 
Jakarta EE and MicroProfile Tech Talk
Jakarta EE and MicroProfile Tech TalkJakarta EE and MicroProfile Tech Talk
Jakarta EE and MicroProfile Tech Talk
 
Bytecode manipulation with Javassist and ASM
Bytecode manipulation with Javassist and ASMBytecode manipulation with Javassist and ASM
Bytecode manipulation with Javassist and ASM
 
Java Technology
Java TechnologyJava Technology
Java Technology
 
CTS Conference Web 2.0 Tutorial Part 2
CTS Conference Web 2.0 Tutorial Part 2CTS Conference Web 2.0 Tutorial Part 2
CTS Conference Web 2.0 Tutorial Part 2
 
Using OSGi in Nakamura
Using OSGi in NakamuraUsing OSGi in Nakamura
Using OSGi in Nakamura
 
Using Sakai with Multiple Locales
Using Sakai with Multiple LocalesUsing Sakai with Multiple Locales
Using Sakai with Multiple Locales
 
Mobile Device APIs
Mobile Device APIsMobile Device APIs
Mobile Device APIs
 
OSGi Community Event 2010 - Enterprise OSGi in WebSphere and Apache Aries
OSGi Community Event 2010 - Enterprise OSGi in WebSphere and Apache AriesOSGi Community Event 2010 - Enterprise OSGi in WebSphere and Apache Aries
OSGi Community Event 2010 - Enterprise OSGi in WebSphere and Apache Aries
 
BarCamp KL H20 Open Social Hackathon
BarCamp KL H20 Open Social HackathonBarCamp KL H20 Open Social Hackathon
BarCamp KL H20 Open Social Hackathon
 
Implementing Web Services In Java
Implementing Web Services In JavaImplementing Web Services In Java
Implementing Web Services In Java
 
Java EE 7 Platform: Boosting Productivity and Embracing HTML5 - Arun Gupta (R...
Java EE 7 Platform: Boosting Productivity and Embracing HTML5 - Arun Gupta (R...Java EE 7 Platform: Boosting Productivity and Embracing HTML5 - Arun Gupta (R...
Java EE 7 Platform: Boosting Productivity and Embracing HTML5 - Arun Gupta (R...
 
Java EE 7: Boosting Productivity and Embracing HTML5
Java EE 7: Boosting Productivity and Embracing HTML5Java EE 7: Boosting Productivity and Embracing HTML5
Java EE 7: Boosting Productivity and Embracing HTML5
 
Timings API: Performance Assertion during the functional testing
 Timings API: Performance Assertion during the functional testing Timings API: Performance Assertion during the functional testing
Timings API: Performance Assertion during the functional testing
 
Easing offline web application development with GWT
Easing offline web application development with GWTEasing offline web application development with GWT
Easing offline web application development with GWT
 
Micronaut Http Client
Micronaut Http ClientMicronaut Http Client
Micronaut Http Client
 
EJB et WS (Montreal JUG - 12 mai 2011)
EJB et WS (Montreal JUG - 12 mai 2011)EJB et WS (Montreal JUG - 12 mai 2011)
EJB et WS (Montreal JUG - 12 mai 2011)
 
From Ruby to Node.js
From Ruby to Node.jsFrom Ruby to Node.js
From Ruby to Node.js
 

Kürzlich hochgeladen

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 

Kürzlich hochgeladen (20)

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 

That’s a nice UI, but have you internationalized your Javascript?

  • 1. That’s a nice UI, but have you internationalized your JavaScript Lovemore Nalube Developer University of Cape Town 17 June 2010
  • 2. Overview Evil ‘n’ Good code Difficulties of i18n-sing JS Why Sakai's needs are unique RESTful access to a Sakai Message bundle DEMO: Course Evaluations and the SMS Credits Transfer tool 2 11th Sakai Conference - June 15-17, 2010
  • 3. Sample nasty code Common evil case: Good case: var response = xhr.status; alert("You have an error caused by" + response); var response = xhr.status; alert(messageLocator.getString( “ui.site.error”, response); 3 11th Sakai Conference - June 15-17, 2010
  • 4. Difficulties of i18n-sing JS Cannot rely on browser locale Most users are unaware of the presence of this browser setting JS alone cannot get Sakai Preferences locale setting Do we have to re-create message bundles? Inconsistencies, more effort, harder to maintain navigator.language /* Mozilla */|| navigator.userLanguage /* IE */  4 11th Sakai Conference - June 15-17, 2010
  • 5. Why Sakai's needs are different 2 stages of language customization: User preference Server configuration Sakai’s own locale lookup is used in many tools Extend this ability to client side tools Date formats vary 5 11th Sakai Conference - June 15-17, 2010
  • 6. Fun stuff Steps to follow 11th Sakai Conference - June 15-17, 2010 6
  • 7. Step 1: RESTful access to a Sakai Message bundle Tool level Entity Provider creates a fixed URI for getting a message bundle In a webapp, make a provider class: ResourceLoader resourceLoader = new ResourceLoader(MESSAGES_BUNDLE_DIR); // eg. where  MESSAGES_BUNDLE_DIR = "org.sakaiproject.evaluation.tool.bundle.messages";             *** NEEDS TO BE A FOLDER! return the key-value equivalents of resourceLoader.entrySet().iterator(); in (for example) HashMap 7 11th Sakai Conference - June 15-17, 2010
  • 8. Step 2: RESTful access to a Sakai Message bundle POM modifications creates a fixed URI for getting a message bundle Depend on Entity Broker: 8 11th Sakai Conference - June 15-17, 2010
  • 9. Step 3: RESTful access to a Sakai Message bundle Call Ajax file at JS doc ready:        $.ajax({            url: “/direct/evals-resources/bundle.json”,            global: false,            cache: true,            dataType : "json",            success: function(messageBundleJSON){                messageBundle = messageBundleJSON.data;            }        }); 9 11th Sakai Conference - June 15-17, 2010
  • 10. Step 4: RESTful access to a Sakai Message bundle Start using: var removalString = fluid.messageLocator( messageBundle )(["administrate.general.enable.response.removal"]);   *** For values with variable replacers like {0}  as in removeitem.removed.user.message: "Item ({0}) has been removed", // Decoding the key "removeitem.removed.user.message". //RESULT  removalString = "Item (3) has been removed" var removalString = fluid.messageLocator( messageBundle )(["removeitem.removed.user.message"], 3 ); 10 11th Sakai Conference - June 15-17, 2010
  • 11. Step 4.5: RESTful access to a Sakai Message bundle Simpler way to use: Get a language string like this: //retrieve the message strings for key messageLocator: function(key, params){ return fluid.messageLocator( messageBundle )([key], params); }, var alertError = evalTemplateUtils.messageLocator("evalsettings.email.sent.from", helpEmail.toLowerCase())); //if helpEmail.toLowerCase() = help@sakaiproject.org //prints: All emails will be sent from help@sakaiproject.org 11 11th Sakai Conference - June 15-17, 2010
  • 12. Course Evaluations SMS Credits Transfer Demo 11th Sakai Conference - June 15-17, 2010 12