<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Srparadk</id>
	<title>Expertiza_Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Srparadk"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Srparadk"/>
	<updated>2026-08-21T21:46:35Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E804_spb&amp;diff=81665</id>
		<title>CSC/ECE 517 Fall 2013/oss E804 spb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E804_spb&amp;diff=81665"/>
		<updated>2013-10-31T00:11:38Z</updated>

		<summary type="html">&lt;p&gt;Srparadk: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Expertiza Code Refactoring&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
A way to query db models to return scores, without UI changes&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Project Description ==&lt;br /&gt;
&lt;br /&gt;
'''Classes:''' &lt;br /&gt;
:models/score.rb (159 lines)&lt;br /&gt;
:grades_controller.rb (241 lines)&lt;br /&gt;
&lt;br /&gt;
'''What needs to be done:''' &lt;br /&gt;
:This code is very slow, due to many factors.  Two of the most prominent are the fact that separate db queries are used for each rubric that has been filled out by anyone associated with the assignment; these queries are made sequentially while the HTML page is being written; and the fact that HTML for the whole page is generated, largely by controller methods, before anything is displayed.&lt;br /&gt;
:Need to refactor the score.rb model which contains complex methods.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Design and Code Changes ==&lt;br /&gt;
&lt;br /&gt;
:The model scores.rb has only two methods that compute scores for the participants based on assignments and courses. But these methods have used hashes extensively to handle data. Also, the method get_total_score() makes many sequential queries to the database which increases the loading time for the page. These functions have logic which can be separated into two methods to make it more modular.&lt;br /&gt;
&lt;br /&gt;
=== Created Database views ===&lt;br /&gt;
&lt;br /&gt;
:Initially the method get_total_scores() was making multiple sequential queries to the database to calculate weighted_scores,sum_of_wieghts and max_question_score. Also, these queries were made to 4 different tables : questions,questionnaire,scores and question_types. This increases the time the page takes to load.&lt;br /&gt;
&lt;br /&gt;
:To reduce the loading time , we merged the multiple queries into a single query by implementing database views. We created a migration &amp;quot;CreateMyViews&amp;quot; that creates a view which has information from all the above 4 tables in one place. So now a single query on that view returns all the three values - weighted_scores,sum_of_wieghts and max_question_score.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Before implementing views:&lt;br /&gt;
 @questionnaire = Questionnaire.find(@questions[0].questionnaire_id)&lt;br /&gt;
 @questions.each {&lt;br /&gt;
          |question|&lt;br /&gt;
        item = Score.find_by_response_id_and_question_id(@response.id, question.id)&lt;br /&gt;
        if item != nil&lt;br /&gt;
          weighted_score += item.score * question.weight&lt;br /&gt;
        end&lt;br /&gt;
        sum_of_weights += question.weight&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
:After implementing views: &lt;br /&gt;
:The each loop making multiple queries to the database is eliminated and a single query does the work instead.&lt;br /&gt;
&lt;br /&gt;
 questionnaireData = MyView.find_by_sql [&amp;quot;SELECT q1_max_question_score ,SUM(question_weight) as sum_of_weights,&lt;br /&gt;
 SUM(question_weight * s_score) as weighted_score &lt;br /&gt;
 FROM my_views WHERE q1_id = ? AND s_response_id = ?&amp;quot;,questions[0].questionnaire_id,response .id]&lt;br /&gt;
   weighted_score = questionnaireData[0].weighted_score.to_f&lt;br /&gt;
   sum_of_weights = questionnaireData[0].sum_of_weights.to_f&lt;br /&gt;
   max_question_score = questionnaireData[0].q1_max_question_score.to_f&lt;br /&gt;
&lt;br /&gt;
=== Separated functionality ===&lt;br /&gt;
:The get_total_scores function computes total scores and also has the code to check if a response is valid or invalid. This code is independent of computation of scores and can be separated into a separate function. We have created a function 'submission_valid?' to check if a given response is valid or not.&lt;br /&gt;
&lt;br /&gt;
=== Reduced the use of hash ===&lt;br /&gt;
:The get_total_scores function accepts a hash as a parameter, which can be avoided. We have refactored the method to accept three arguments instead of a hash. We had to change all the dependent classes that call this method.&lt;br /&gt;
:The compute_scores method returns a hash that stores the minimum, maximum and average score. We created a class ParticipantScore.rb that has attributes min, max and avg which store the minimum, maximum and average score of a particpant. This object could be used to maintain state as against an hash. Now the compute_score method returns an object of class ParticipantScore instead of an hash.&lt;br /&gt;
&lt;br /&gt;
== Performance Comparison with refactored code ==&lt;br /&gt;
:Existing Code:&lt;br /&gt;
[[File:before.png]]&lt;br /&gt;
&lt;br /&gt;
:Refactored Code:&lt;br /&gt;
[[File:After.png]]&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
&lt;br /&gt;
:Several model classes namely; assignment.rb, participant.rb, score.rb include extensive use of hashes and with high depths: a hash within a hash within a hash. These classes could be modified to reduce the use of hash and use an object instead. Also, database views can be used in place of code that makes multiple sequential queries to reduce the loading time of pages.&lt;/div&gt;</summary>
		<author><name>Srparadk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E804_spb&amp;diff=81658</id>
		<title>CSC/ECE 517 Fall 2013/oss E804 spb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E804_spb&amp;diff=81658"/>
		<updated>2013-10-31T00:08:17Z</updated>

		<summary type="html">&lt;p&gt;Srparadk: /* Performance Comparison with refactored code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Expertiza Code Refactoring&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
A way to query db models to return scores, without UI changes&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Project Description ==&lt;br /&gt;
&lt;br /&gt;
'''Classes:''' &lt;br /&gt;
:models/score.rb (159 lines)&lt;br /&gt;
:grades_controller.rb (241 lines)&lt;br /&gt;
&lt;br /&gt;
'''What needs to be done:''' &lt;br /&gt;
:This code is very slow, due to many factors.  Two of the most prominent are the fact that separate db queries are used for each rubric that has been filled out by anyone associated with the assignment; these queries are made sequentially while the HTML page is being written; and the fact that HTML for the whole page is generated, largely by controller methods, before anything is displayed.&lt;br /&gt;
:Need to refactor the score.rb model which contains complex methods.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Design and Code Changes ==&lt;br /&gt;
&lt;br /&gt;
:The model scores.rb has only two methods that compute scores for the participants based on assignments and courses. But these methods have used hashes extensively to handle data. Also, the method get_total_score() makes many sequential queries to the database which increases the loading time for the page. These functions have logic which can be separated into two methods to make it more modular.&lt;br /&gt;
&lt;br /&gt;
=== Created Database views ===&lt;br /&gt;
&lt;br /&gt;
:Initially the method get_total_scores() was making multiple sequential queries to the database to calculate weighted_scores,sum_of_wieghts and max_question_score. Also, these queries were made to 4 different tables : questions,questionnaire,scores and question_types. This increases the time the page takes to load.&lt;br /&gt;
&lt;br /&gt;
:To reduce the loading time , we merged the multiple queries into a single query by implementing database views. We created a migration &amp;quot;CreateMyViews&amp;quot; that creates a view which has information from all the above 4 tables in one place. So now a single query on that view returns all the three values - weighted_scores,sum_of_wieghts and max_question_score.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Before implementing views:&lt;br /&gt;
 @questionnaire = Questionnaire.find(@questions[0].questionnaire_id)&lt;br /&gt;
 @questions.each {&lt;br /&gt;
          |question|&lt;br /&gt;
        item = Score.find_by_response_id_and_question_id(@response.id, question.id)&lt;br /&gt;
        if item != nil&lt;br /&gt;
          weighted_score += item.score * question.weight&lt;br /&gt;
        end&lt;br /&gt;
        sum_of_weights += question.weight&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
:After implementing views: &lt;br /&gt;
:The each loop making multiple queries to the database is eliminated and a single query does the work instead.&lt;br /&gt;
&lt;br /&gt;
 questionnaireData = MyView.find_by_sql [&amp;quot;SELECT q1_max_question_score ,SUM(question_weight) as sum_of_weights,&lt;br /&gt;
 SUM(question_weight * s_score) as weighted_score &lt;br /&gt;
 FROM my_views WHERE q1_id = ? AND s_response_id = ?&amp;quot;,questions[0].questionnaire_id,response .id]&lt;br /&gt;
   weighted_score = questionnaireData[0].weighted_score.to_f&lt;br /&gt;
   sum_of_weights = questionnaireData[0].sum_of_weights.to_f&lt;br /&gt;
   max_question_score = questionnaireData[0].q1_max_question_score.to_f&lt;br /&gt;
&lt;br /&gt;
=== Separated functionality ===&lt;br /&gt;
:The get_total_scores function computes total scores and also has the code to check if a response is valid or invalid. This code is independent of computation of scores and can be separated into a separate function. We have created a function 'submission_valid?' to check if a given response is valid or not.&lt;br /&gt;
&lt;br /&gt;
=== Reduced the use of hash ===&lt;br /&gt;
:The get_total_scores function accepts a hash as a parameter, which can be avoided. We have refactored the method to accept three arguments instead of a hash. We had to change all the dependent classes that call this method.&lt;br /&gt;
:The compute_scores method returns a hash that stores the minimum, maximum and average score. We created a class ParticipantScore.rb that has attributes min, max and avg which store the minimum, maximum and average score of a particpant. This object could be used to maintain state as against an hash. Now the compute_score method returns an object of class ParticipantScore instead of an hash.&lt;br /&gt;
&lt;br /&gt;
== Performance Comparison with refactored code ==&lt;br /&gt;
:Existing Code:&lt;br /&gt;
[[File:before.png]]&lt;br /&gt;
&lt;br /&gt;
:Refactored Code:&lt;br /&gt;
[[File:After.png]]&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
&lt;br /&gt;
:Several model classes namely; assignment.rb, participant.rb, score.rb include extensive use of hashes and with high depths: a hash within a hash within a hash. These classes could be modified to reduce the use of hash and use an object instead. Also, database views can be used in place of code that makes multiple sequential queries to reduce the loading time of pages.&lt;br /&gt;
&lt;br /&gt;
== Setup Issues ==&lt;/div&gt;</summary>
		<author><name>Srparadk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E804_spb&amp;diff=81656</id>
		<title>CSC/ECE 517 Fall 2013/oss E804 spb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E804_spb&amp;diff=81656"/>
		<updated>2013-10-31T00:07:57Z</updated>

		<summary type="html">&lt;p&gt;Srparadk: /* Comparison of performance with refactored code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Expertiza Code Refactoring&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
A way to query db models to return scores, without UI changes&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Project Description ==&lt;br /&gt;
&lt;br /&gt;
'''Classes:''' &lt;br /&gt;
:models/score.rb (159 lines)&lt;br /&gt;
:grades_controller.rb (241 lines)&lt;br /&gt;
&lt;br /&gt;
'''What needs to be done:''' &lt;br /&gt;
:This code is very slow, due to many factors.  Two of the most prominent are the fact that separate db queries are used for each rubric that has been filled out by anyone associated with the assignment; these queries are made sequentially while the HTML page is being written; and the fact that HTML for the whole page is generated, largely by controller methods, before anything is displayed.&lt;br /&gt;
:Need to refactor the score.rb model which contains complex methods.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Design and Code Changes ==&lt;br /&gt;
&lt;br /&gt;
:The model scores.rb has only two methods that compute scores for the participants based on assignments and courses. But these methods have used hashes extensively to handle data. Also, the method get_total_score() makes many sequential queries to the database which increases the loading time for the page. These functions have logic which can be separated into two methods to make it more modular.&lt;br /&gt;
&lt;br /&gt;
=== Created Database views ===&lt;br /&gt;
&lt;br /&gt;
:Initially the method get_total_scores() was making multiple sequential queries to the database to calculate weighted_scores,sum_of_wieghts and max_question_score. Also, these queries were made to 4 different tables : questions,questionnaire,scores and question_types. This increases the time the page takes to load.&lt;br /&gt;
&lt;br /&gt;
:To reduce the loading time , we merged the multiple queries into a single query by implementing database views. We created a migration &amp;quot;CreateMyViews&amp;quot; that creates a view which has information from all the above 4 tables in one place. So now a single query on that view returns all the three values - weighted_scores,sum_of_wieghts and max_question_score.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Before implementing views:&lt;br /&gt;
 @questionnaire = Questionnaire.find(@questions[0].questionnaire_id)&lt;br /&gt;
 @questions.each {&lt;br /&gt;
          |question|&lt;br /&gt;
        item = Score.find_by_response_id_and_question_id(@response.id, question.id)&lt;br /&gt;
        if item != nil&lt;br /&gt;
          weighted_score += item.score * question.weight&lt;br /&gt;
        end&lt;br /&gt;
        sum_of_weights += question.weight&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
:After implementing views: &lt;br /&gt;
:The each loop making multiple queries to the database is eliminated and a single query does the work instead.&lt;br /&gt;
&lt;br /&gt;
 questionnaireData = MyView.find_by_sql [&amp;quot;SELECT q1_max_question_score ,SUM(question_weight) as sum_of_weights,&lt;br /&gt;
 SUM(question_weight * s_score) as weighted_score &lt;br /&gt;
 FROM my_views WHERE q1_id = ? AND s_response_id = ?&amp;quot;,questions[0].questionnaire_id,response .id]&lt;br /&gt;
   weighted_score = questionnaireData[0].weighted_score.to_f&lt;br /&gt;
   sum_of_weights = questionnaireData[0].sum_of_weights.to_f&lt;br /&gt;
   max_question_score = questionnaireData[0].q1_max_question_score.to_f&lt;br /&gt;
&lt;br /&gt;
=== Separated functionality ===&lt;br /&gt;
:The get_total_scores function computes total scores and also has the code to check if a response is valid or invalid. This code is independent of computation of scores and can be separated into a separate function. We have created a function 'submission_valid?' to check if a given response is valid or not.&lt;br /&gt;
&lt;br /&gt;
=== Reduced the use of hash ===&lt;br /&gt;
:The get_total_scores function accepts a hash as a parameter, which can be avoided. We have refactored the method to accept three arguments instead of a hash. We had to change all the dependent classes that call this method.&lt;br /&gt;
:The compute_scores method returns a hash that stores the minimum, maximum and average score. We created a class ParticipantScore.rb that has attributes min, max and avg which store the minimum, maximum and average score of a particpant. This object could be used to maintain state as against an hash. Now the compute_score method returns an object of class ParticipantScore instead of an hash.&lt;br /&gt;
&lt;br /&gt;
== Performance Comparison with refactored code ==&lt;br /&gt;
:Existing Code:&lt;br /&gt;
[[File:before.png]]&lt;br /&gt;
&lt;br /&gt;
:Refactored Code:&lt;br /&gt;
[[File:After.jpg]]&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
&lt;br /&gt;
:Several model classes namely; assignment.rb, participant.rb, score.rb include extensive use of hashes and with high depths: a hash within a hash within a hash. These classes could be modified to reduce the use of hash and use an object instead. Also, database views can be used in place of code that makes multiple sequential queries to reduce the loading time of pages.&lt;br /&gt;
&lt;br /&gt;
== Setup Issues ==&lt;/div&gt;</summary>
		<author><name>Srparadk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:After.png&amp;diff=81655</id>
		<title>File:After.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:After.png&amp;diff=81655"/>
		<updated>2013-10-31T00:07:39Z</updated>

		<summary type="html">&lt;p&gt;Srparadk: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Srparadk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E804_spb&amp;diff=81649</id>
		<title>CSC/ECE 517 Fall 2013/oss E804 spb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E804_spb&amp;diff=81649"/>
		<updated>2013-10-31T00:05:16Z</updated>

		<summary type="html">&lt;p&gt;Srparadk: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Expertiza Code Refactoring&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
A way to query db models to return scores, without UI changes&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Project Description ==&lt;br /&gt;
&lt;br /&gt;
'''Classes:''' &lt;br /&gt;
:models/score.rb (159 lines)&lt;br /&gt;
:grades_controller.rb (241 lines)&lt;br /&gt;
&lt;br /&gt;
'''What needs to be done:''' &lt;br /&gt;
:This code is very slow, due to many factors.  Two of the most prominent are the fact that separate db queries are used for each rubric that has been filled out by anyone associated with the assignment; these queries are made sequentially while the HTML page is being written; and the fact that HTML for the whole page is generated, largely by controller methods, before anything is displayed.&lt;br /&gt;
:Need to refactor the score.rb model which contains complex methods.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Design and Code Changes ==&lt;br /&gt;
&lt;br /&gt;
:The model scores.rb has only two methods that compute scores for the participants based on assignments and courses. But these methods have used hashes extensively to handle data. Also, the method get_total_score() makes many sequential queries to the database which increases the loading time for the page. These functions have logic which can be separated into two methods to make it more modular.&lt;br /&gt;
&lt;br /&gt;
=== Created Database views ===&lt;br /&gt;
&lt;br /&gt;
:Initially the method get_total_scores() was making multiple sequential queries to the database to calculate weighted_scores,sum_of_wieghts and max_question_score. Also, these queries were made to 4 different tables : questions,questionnaire,scores and question_types. This increases the time the page takes to load.&lt;br /&gt;
&lt;br /&gt;
:To reduce the loading time , we merged the multiple queries into a single query by implementing database views. We created a migration &amp;quot;CreateMyViews&amp;quot; that creates a view which has information from all the above 4 tables in one place. So now a single query on that view returns all the three values - weighted_scores,sum_of_wieghts and max_question_score.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Before implementing views:&lt;br /&gt;
 @questionnaire = Questionnaire.find(@questions[0].questionnaire_id)&lt;br /&gt;
 @questions.each {&lt;br /&gt;
          |question|&lt;br /&gt;
        item = Score.find_by_response_id_and_question_id(@response.id, question.id)&lt;br /&gt;
        if item != nil&lt;br /&gt;
          weighted_score += item.score * question.weight&lt;br /&gt;
        end&lt;br /&gt;
        sum_of_weights += question.weight&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
:After implementing views: &lt;br /&gt;
:The each loop making multiple queries to the database is eliminated and a single query does the work instead.&lt;br /&gt;
&lt;br /&gt;
 questionnaireData = MyView.find_by_sql [&amp;quot;SELECT q1_max_question_score ,SUM(question_weight) as sum_of_weights,&lt;br /&gt;
 SUM(question_weight * s_score) as weighted_score &lt;br /&gt;
 FROM my_views WHERE q1_id = ? AND s_response_id = ?&amp;quot;,questions[0].questionnaire_id,response .id]&lt;br /&gt;
   weighted_score = questionnaireData[0].weighted_score.to_f&lt;br /&gt;
   sum_of_weights = questionnaireData[0].sum_of_weights.to_f&lt;br /&gt;
   max_question_score = questionnaireData[0].q1_max_question_score.to_f&lt;br /&gt;
&lt;br /&gt;
=== Separated functionality ===&lt;br /&gt;
:The get_total_scores function computes total scores and also has the code to check if a response is valid or invalid. This code is independent of computation of scores and can be separated into a separate function. We have created a function 'submission_valid?' to check if a given response is valid or not.&lt;br /&gt;
&lt;br /&gt;
=== Reduced the use of hash ===&lt;br /&gt;
:The get_total_scores function accepts a hash as a parameter, which can be avoided. We have refactored the method to accept three arguments instead of a hash. We had to change all the dependent classes that call this method.&lt;br /&gt;
:The compute_scores method returns a hash that stores the minimum, maximum and average score. We created a class ParticipantScore.rb that has attributes min, max and avg which store the minimum, maximum and average score of a particpant. This object could be used to maintain state as against an hash. Now the compute_score method returns an object of class ParticipantScore instead of an hash.&lt;br /&gt;
&lt;br /&gt;
== Comparison of performance with refactored code ==&lt;br /&gt;
&lt;br /&gt;
[[File:before.png]]&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
&lt;br /&gt;
:Several model classes namely; assignment.rb, participant.rb, score.rb include extensive use of hashes and with high depths: a hash within a hash within a hash. These classes could be modified to reduce the use of hash and use an object instead. Also, database views can be used in place of code that makes multiple sequential queries to reduce the loading time of pages.&lt;br /&gt;
&lt;br /&gt;
== Setup Issues ==&lt;/div&gt;</summary>
		<author><name>Srparadk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Before.png&amp;diff=81648</id>
		<title>File:Before.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Before.png&amp;diff=81648"/>
		<updated>2013-10-31T00:04:26Z</updated>

		<summary type="html">&lt;p&gt;Srparadk: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Srparadk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E804_spb&amp;diff=81646</id>
		<title>CSC/ECE 517 Fall 2013/oss E804 spb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E804_spb&amp;diff=81646"/>
		<updated>2013-10-31T00:03:19Z</updated>

		<summary type="html">&lt;p&gt;Srparadk: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Expertiza Code Refactoring&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
A way to query db models to return scores, without UI changes&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Project Description ==&lt;br /&gt;
&lt;br /&gt;
'''Classes:''' &lt;br /&gt;
:models/score.rb (159 lines)&lt;br /&gt;
:grades_controller.rb (241 lines)&lt;br /&gt;
&lt;br /&gt;
'''What needs to be done:''' &lt;br /&gt;
:This code is very slow, due to many factors.  Two of the most prominent are the fact that separate db queries are used for each rubric that has been filled out by anyone associated with the assignment; these queries are made sequentially while the HTML page is being written; and the fact that HTML for the whole page is generated, largely by controller methods, before anything is displayed.&lt;br /&gt;
:Need to refactor the score.rb model which contains complex methods.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Design and Code Changes ==&lt;br /&gt;
&lt;br /&gt;
:The model scores.rb has only two methods that compute scores for the participants based on assignments and courses. But these methods have used hashes extensively to handle data. Also, the method get_total_score() makes many sequential queries to the database which increases the loading time for the page. These functions have logic which can be separated into two methods to make it more modular.&lt;br /&gt;
&lt;br /&gt;
=== Created Database views ===&lt;br /&gt;
&lt;br /&gt;
:Initially the method get_total_scores() was making multiple sequential queries to the database to calculate weighted_scores,sum_of_wieghts and max_question_score. Also, these queries were made to 4 different tables : questions,questionnaire,scores and question_types. This increases the time the page takes to load.&lt;br /&gt;
&lt;br /&gt;
:To reduce the loading time , we merged the multiple queries into a single query by implementing database views. We created a migration &amp;quot;CreateMyViews&amp;quot; that creates a view which has information from all the above 4 tables in one place. So now a single query on that view returns all the three values - weighted_scores,sum_of_wieghts and max_question_score.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Before implementing views:&lt;br /&gt;
 @questionnaire = Questionnaire.find(@questions[0].questionnaire_id)&lt;br /&gt;
 @questions.each {&lt;br /&gt;
          |question|&lt;br /&gt;
        item = Score.find_by_response_id_and_question_id(@response.id, question.id)&lt;br /&gt;
        if item != nil&lt;br /&gt;
          weighted_score += item.score * question.weight&lt;br /&gt;
        end&lt;br /&gt;
        sum_of_weights += question.weight&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
:After implementing views: &lt;br /&gt;
:The each loop making multiple queries to the database is eliminated and a single query does the work instead.&lt;br /&gt;
&lt;br /&gt;
 questionnaireData = MyView.find_by_sql [&amp;quot;SELECT q1_max_question_score ,SUM(question_weight) as sum_of_weights,&lt;br /&gt;
 SUM(question_weight * s_score) as weighted_score &lt;br /&gt;
 FROM my_views WHERE q1_id = ? AND s_response_id = ?&amp;quot;,questions[0].questionnaire_id,response .id]&lt;br /&gt;
   weighted_score = questionnaireData[0].weighted_score.to_f&lt;br /&gt;
   sum_of_weights = questionnaireData[0].sum_of_weights.to_f&lt;br /&gt;
   max_question_score = questionnaireData[0].q1_max_question_score.to_f&lt;br /&gt;
&lt;br /&gt;
=== Separated functionality ===&lt;br /&gt;
:The get_total_scores function computes total scores and also has the code to check if a response is valid or invalid. This code is independent of computation of scores and can be separated into a separate function. We have created a function 'submission_valid?' to check if a given response is valid or not.&lt;br /&gt;
&lt;br /&gt;
=== Reduced the use of hash ===&lt;br /&gt;
:The get_total_scores function accepts a hash as a parameter, which can be avoided. We have refactored the method to accept three arguments instead of a hash. We had to change all the dependent classes that call this method.&lt;br /&gt;
:The compute_scores method returns a hash that stores the minimum, maximum and average score. We created a class ParticipantScore.rb that has attributes min, max and avg which store the minimum, maximum and average score of a particpant. This object could be used to maintain state as against an hash. Now the compute_score method returns an object of class ParticipantScore instead of an hash.&lt;br /&gt;
&lt;br /&gt;
== Comparison of performance with refactored code ==&lt;br /&gt;
&lt;br /&gt;
[[Media:before.png]]&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
&lt;br /&gt;
:Several model classes namely; assignment.rb, participant.rb, score.rb include extensive use of hashes and with high depths: a hash within a hash within a hash. These classes could be modified to reduce the use of hash and use an object instead. Also, database views can be used in place of code that makes multiple sequential queries to reduce the loading time of pages.&lt;br /&gt;
&lt;br /&gt;
== Setup Issues ==&lt;/div&gt;</summary>
		<author><name>Srparadk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E804_spb&amp;diff=81604</id>
		<title>CSC/ECE 517 Fall 2013/oss E804 spb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E804_spb&amp;diff=81604"/>
		<updated>2013-10-30T23:39:58Z</updated>

		<summary type="html">&lt;p&gt;Srparadk: /* Created Database views */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Expertiza Code Refactoring&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
A way to query db models to return scores, without UI changes&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Project Description ==&lt;br /&gt;
&lt;br /&gt;
'''Classes:''' &lt;br /&gt;
:models/score.rb (159 lines)&lt;br /&gt;
:grades_controller.rb (241 lines)&lt;br /&gt;
&lt;br /&gt;
'''What needs to be done:''' &lt;br /&gt;
:This code is very slow, due to many factors.  Two of the most prominent are the fact that separate db queries are used for each rubric that has been filled out by anyone associated with the assignment; these queries are made sequentially while the HTML page is being written; and the fact that HTML for the whole page is generated, largely by controller methods, before anything is displayed.&lt;br /&gt;
:Need to refactor the score.rb model which contains complex methods.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Design and Code Changes ==&lt;br /&gt;
&lt;br /&gt;
:The model scores.rb has only two methods that compute scores for the participants based on assignments and courses. But these methods have used hashes extensively to handle data. Also, the method get_total_score() makes many sequential queries to the database which increases the loading time for the page. These functions have logic which can be separated into two methods to make it more modular.&lt;br /&gt;
&lt;br /&gt;
=== Created Database views ===&lt;br /&gt;
&lt;br /&gt;
:Initially the method get_total_scores() was making multiple sequential queries to the database to calculate weighted_scores,sum_of_wieghts and max_question_score. Also, these queries were made to 4 different tables : questions,questionnaire,scores and question_types. This increases the time the page takes to load.&lt;br /&gt;
&lt;br /&gt;
:To reduce the loading time , we merged the multiple queries into a single query by implementing database views. We created a migration &amp;quot;CreateMyViews&amp;quot; that creates a view which has information from all the above 4 tables in one place. So now a single query on that view returns all the three values - weighted_scores,sum_of_wieghts and max_question_score.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Before implementing views:&lt;br /&gt;
 @questionnaire = Questionnaire.find(@questions[0].questionnaire_id)&lt;br /&gt;
 @questions.each {&lt;br /&gt;
          |question|&lt;br /&gt;
        item = Score.find_by_response_id_and_question_id(@response.id, question.id)&lt;br /&gt;
        if item != nil&lt;br /&gt;
          weighted_score += item.score * question.weight&lt;br /&gt;
        end&lt;br /&gt;
        sum_of_weights += question.weight&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
:After implementing views: &lt;br /&gt;
:The each loop making multiple queries to the database is eliminated and a single query does the work instead.&lt;br /&gt;
&lt;br /&gt;
 questionnaireData = MyView.find_by_sql [&amp;quot;SELECT q1_max_question_score ,SUM(question_weight) as sum_of_weights,&lt;br /&gt;
 SUM(question_weight * s_score) as weighted_score &lt;br /&gt;
 FROM my_views WHERE q1_id = ? AND s_response_id = ?&amp;quot;,questions[0].questionnaire_id,response .id]&lt;br /&gt;
   weighted_score = questionnaireData[0].weighted_score.to_f&lt;br /&gt;
   sum_of_weights = questionnaireData[0].sum_of_weights.to_f&lt;br /&gt;
   max_question_score = questionnaireData[0].q1_max_question_score.to_f&lt;br /&gt;
&lt;br /&gt;
=== Separated functionality ===&lt;br /&gt;
:The get_total_scores function computes total scores and also has the code to check if a response is valid or invalid. This code is independent of computation of scores and can be separated into a separate function. We have created a function 'submission_valid?' to check if a given response is valid or not.&lt;br /&gt;
&lt;br /&gt;
=== Reduced the use of hash ===&lt;br /&gt;
:The get_total_scores function accepts a hash as a parameter, which can be avoided. We have refactored the method to accept three arguments instead of a hash. We had to change all the dependent classes that call this method.&lt;br /&gt;
:The compute_scores method returns a hash that stores the minimum, maximum and average score. We created a class ParticipantScore.rb that has attributes min, max and avg which store the minimum, maximum and average score of a particpant. This object could be used to maintain state as against an hash. Now the compute_score method returns an object of class ParticipantScore instead of an hash.&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
&lt;br /&gt;
:Several model classes namely; assignment.rb, participant.rb, score.rb include extensive use of hashes and with high depths: a hash within a hash within a hash. These classes could be modified to reduce the use of hash and use an object instead. Also, database views can be used in place of code that makes multiple sequential queries to reduce the loading time of pages.&lt;br /&gt;
&lt;br /&gt;
== Setup Issues ==&lt;/div&gt;</summary>
		<author><name>Srparadk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E804_spb&amp;diff=81552</id>
		<title>CSC/ECE 517 Fall 2013/oss E804 spb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E804_spb&amp;diff=81552"/>
		<updated>2013-10-30T23:17:45Z</updated>

		<summary type="html">&lt;p&gt;Srparadk: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Expertiza Code Refactoring&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
A way to query db models to return scores, without UI changes&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Project Description ==&lt;br /&gt;
&lt;br /&gt;
'''Classes:''' &lt;br /&gt;
:models/score.rb (159 lines)&lt;br /&gt;
:grades_controller.rb (241 lines)&lt;br /&gt;
&lt;br /&gt;
'''What needs to be done:''' &lt;br /&gt;
:This code is very slow, due to many factors.  Two of the most prominent are the fact that separate db queries are used for each rubric that has been filled out by anyone associated with the assignment; these queries are made sequentially while the HTML page is being written; and the fact that HTML for the whole page is generated, largely by controller methods, before anything is displayed.&lt;br /&gt;
:Need to refactor the score.rb model which contains complex methods.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Design and Code Changes ==&lt;br /&gt;
&lt;br /&gt;
:The model scores.rb has only two methods that compute scores for the participants based on assignments and courses. But these methods have used hashes extensively to handle data. Also, the method get_total_score() makes many sequential queries to the database which increases the loading time for the page. These functions have logic which can be separated into two methods to make it more modular.&lt;br /&gt;
&lt;br /&gt;
=== Created Database views ===&lt;br /&gt;
&lt;br /&gt;
:Initially the method get_total_scores() was making multiple sequential queries to the database to calculate weighted_scores,sum_of_wieghts and max_question_score. Also, these queries were made to 4 different tables : questions,questionnaire,scores and question_types. This increases the time the page takes to load.&lt;br /&gt;
&lt;br /&gt;
:To reduce the loading time , we merged the multiple queries into a single query by implementing database views. We created a migration &amp;quot;CreateMyViews&amp;quot; that creates a view which has information from all the above 4 tables in one place. So now a single query on that view returns all the three values - weighted_scores,sum_of_wieghts and max_question_score.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Before implementing views:&lt;br /&gt;
 @questionnaire = Questionnaire.find(@questions[0].questionnaire_id)&lt;br /&gt;
 @questions.each {&lt;br /&gt;
          |question|&lt;br /&gt;
        item = Score.find_by_response_id_and_question_id(@response.id, question.id)&lt;br /&gt;
        if item != nil&lt;br /&gt;
          weighted_score += item.score * question.weight&lt;br /&gt;
        end&lt;br /&gt;
        sum_of_weights += question.weight&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
:After implementing views:&lt;br /&gt;
&lt;br /&gt;
 questionnaireData = MyView.find_by_sql [&amp;quot;SELECT q1_max_question_score ,SUM(question_weight) as sum_of_weights,&lt;br /&gt;
 SUM(question_weight * s_score) as weighted_score &lt;br /&gt;
 FROM my_views WHERE q1_id = ? AND s_response_id = ?&amp;quot;,questions[0].questionnaire_id,response .id]&lt;br /&gt;
   weighted_score = questionnaireData[0].weighted_score.to_f&lt;br /&gt;
   sum_of_weights = questionnaireData[0].sum_of_weights.to_f&lt;br /&gt;
   max_question_score = questionnaireData[0].q1_max_question_score.to_f&lt;br /&gt;
&lt;br /&gt;
=== Separated functionality ===&lt;br /&gt;
:The get_total_scores function computes total scores and also has the code to check if a response is valid or invalid. This code is independent of computation of scores and can be separated into a separate function. We have created a function 'submission_valid?' to check if a given response is valid or not.&lt;br /&gt;
&lt;br /&gt;
=== Reduced the use of hash ===&lt;br /&gt;
:The get_total_scores function accepts a hash as a parameter, which can be avoided. We have refactored the method to accept three arguments instead of a hash. We had to change all the dependent classes that call this method.&lt;br /&gt;
:The compute_scores method returns a hash that stores the minimum, maximum and average score. We created a class ParticipantScore.rb that has attributes min, max and avg which store the minimum, maximum and average score of a particpant. This object could be used to maintain state as against an hash. Now the compute_score method returns an object of class ParticipantScore instead of an hash.&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
&lt;br /&gt;
:Several model classes namely; assignment.rb, participant.rb, score.rb include extensive use of hashes and with high depths: a hash within a hash within a hash. These classes could be modified to reduce the use of hash and use an object instead. Also, database views can be used in place of code that makes multiple sequential queries to reduce the loading time of pages.&lt;br /&gt;
&lt;br /&gt;
== Setup Issues ==&lt;/div&gt;</summary>
		<author><name>Srparadk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E804_spb&amp;diff=81197</id>
		<title>CSC/ECE 517 Fall 2013/oss E804 spb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E804_spb&amp;diff=81197"/>
		<updated>2013-10-30T19:34:53Z</updated>

		<summary type="html">&lt;p&gt;Srparadk: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Expertiza Code Refactoring&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
A way to query db models to return scores, without UI changes&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Project Description ==&lt;br /&gt;
&lt;br /&gt;
'''Classes:''' &lt;br /&gt;
:models/score.rb (159 lines)&lt;br /&gt;
:grades_controller.rb (241 lines)&lt;br /&gt;
&lt;br /&gt;
'''What needs to be done:''' &lt;br /&gt;
:This code is very slow, due to many factors.  Two of the most prominent are the fact that separate db queries are used for each rubric that has been filled out by anyone associated with the assignment; these queries are made sequentially while the HTML page is being written; and the fact that HTML for the whole page is generated, largely by controller methods, before anything is displayed.&lt;br /&gt;
:Need to refactor the score.rb model which contains complex methods.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Design and Code Changes ==&lt;br /&gt;
&lt;br /&gt;
:The model scores.rb has only two methods that compute scores for the participants based on assignments and courses. But these methods have used hashes extensively to handle data. Also, the method get_total_score() makes many sequential queries to the database which increases the loading time for the page. These functions have logic which can be separated into two methods to make it more modular.&lt;br /&gt;
&lt;br /&gt;
=== Created Database views ===&lt;br /&gt;
&lt;br /&gt;
:Initially the method get_total_scores() was making multiple sequential queries to the database to calculate weighted_scores,sum_of_wieghts and max_question_score. Also, these queries were made to 4 different tables : questions,questionnaire,scores and question_types. This increases the time the page takes to load.&lt;br /&gt;
&lt;br /&gt;
:To reduce the loading time , we merged the multiple queries into a single query by implementing database views. We created a migration &amp;quot;CreateMyViews&amp;quot; that creates a view which has information from all the above 4 tables in one place. So now a single query on that view returns all the three values - weighted_scores,sum_of_wieghts and max_question_score.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Before implementing views:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:After implementing views:&lt;br /&gt;
&lt;br /&gt;
 questionnaireData = MyView.find_by_sql [&amp;quot;SELECT q1_max_question_score ,SUM(question_weight) as sum_of_weights,SUM(question_weight * s_score) as weighted_score &lt;br /&gt;
 FROM my_views WHERE q1_id = ? AND s_response_id = ?&amp;quot;,questions[0].questionnaire_id,response .id]&lt;br /&gt;
   weighted_score = questionnaireData[0].weighted_score.to_f&lt;br /&gt;
   sum_of_weights = questionnaireData[0].sum_of_weights.to_f&lt;br /&gt;
   max_question_score = questionnaireData[0].q1_max_question_score.to_f&lt;br /&gt;
&lt;br /&gt;
=== Separated functionality ===&lt;br /&gt;
:The get_total_scores function computes total scores and also has the code to check if a response is valid or invalid. This code is independent of computation of scores and can be separated into a separate function. We have created a function 'submission_valid?' to check if a given response is valid or not.&lt;br /&gt;
&lt;br /&gt;
=== Reduced the use of hash ===&lt;br /&gt;
:the get_total_scores function accepts a hash as a parameter, which can be avoided. We have refactored the method to accept three arguments instead of a hash. We had to change all the dependent classes that call this method.&lt;br /&gt;
:the compute_scores method returns a hash that stores the minimum, maximum and average score. We created a class ParticipantScore.rb that has attributes min, max and avg which store the minimum, maximum and average score of a particpant. This object could be used to maintain state as against an hash. Now the compute_score method returns an object of class ParticipantScore instead of an hash.&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
&lt;br /&gt;
:Several model classes namely; assignment.rb, participant.rb, score.rb include extensive use of hashes and with high depths: a hash within a hash within a hash. These classes could be modified to reduce the use of hash and use an object instead. Also, database views can be used in place of code that makes multiple sequential queries to reduce the loading time of pages.&lt;br /&gt;
&lt;br /&gt;
== Setup Issues ==&lt;/div&gt;</summary>
		<author><name>Srparadk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E804_spb&amp;diff=81163</id>
		<title>CSC/ECE 517 Fall 2013/oss E804 spb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E804_spb&amp;diff=81163"/>
		<updated>2013-10-30T19:21:04Z</updated>

		<summary type="html">&lt;p&gt;Srparadk: /* Created Database views */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Expertiza Code Refactoring&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
A way to query db models to return scores, without UI changes&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Project Description ==&lt;br /&gt;
&lt;br /&gt;
'''Classes:''' &lt;br /&gt;
:models/score.rb (159 lines)&lt;br /&gt;
:grades_controller.rb (241 lines)&lt;br /&gt;
&lt;br /&gt;
'''What needs to be done:''' &lt;br /&gt;
:This code is very slow, due to many factors.  Two of the most prominent are the fact that separate db queries are used for each rubric that has been filled out by anyone associated with the assignment; these queries are made sequentially while the HTML page is being written; and the fact that HTML for the whole page is generated, largely by controller methods, before anything is displayed.&lt;br /&gt;
:Need to refactor the score.rb model which contains complex methods.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Design Changes ==&lt;br /&gt;
&lt;br /&gt;
:The model scores.rb has only two methods that compute scores for the participants based on assignments and courses. But these methods have used hashes extensively to handle data. Also, the method get_total_score() makes many sequential queries to the database which increases the loading time for the page. These functions have logic which can be separated into two methods to make it more modular.&lt;br /&gt;
&lt;br /&gt;
=== Created Database views ===&lt;br /&gt;
&lt;br /&gt;
:Initially the method get_total_scores() was making multiple sequential queries to the database to calculate weighted_scores,sum_of_wieghts and max_question_score. Also, these queries were made to 4 different tables : questions,questionnaire,scores and question_types. This increases the time the page takes to load.&lt;br /&gt;
&lt;br /&gt;
:To reduce the loading time , we merged the multiple queries into a single query by implementing database views. We created a migration &amp;quot;CreateMyViews&amp;quot; that creates a view which has information from all the above 4 tables in one place. So now a single query on that view returns all the three values - weighted_scores,sum_of_wieghts and max_question_score.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Before implementing views:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:After implementing views:&lt;br /&gt;
&lt;br /&gt;
 questionnaireData = MyView.find_by_sql [&amp;quot;SELECT q1_max_question_score ,SUM(question_weight) as sum_of_weights,SUM(question_weight * s_score) as weighted_score &lt;br /&gt;
 FROM my_views WHERE q1_id = ? AND s_response_id = ?&amp;quot;,questions[0].questionnaire_id,response .id]&lt;br /&gt;
   weighted_score = questionnaireData[0].weighted_score.to_f&lt;br /&gt;
   sum_of_weights = questionnaireData[0].sum_of_weights.to_f&lt;br /&gt;
   max_question_score = questionnaireData[0].q1_max_question_score.to_f&lt;br /&gt;
&lt;br /&gt;
=== Separated functionality ===&lt;br /&gt;
:The get_total_scores function computes total scores and also has the code to check if a response is valid or invalid. This code is independent of computation of scores and can be separated into a separate function. We have created a function 'submission_valid?' to check if a given response is valid or not.&lt;br /&gt;
&lt;br /&gt;
=== Reduced the use of hash ===&lt;br /&gt;
:the get_total_scores function accepts a hash as a parameter, which can be avoided. We have refactored the method to accept three arguments instead of a hash. We had to change all the dependent classes that call this method.&lt;br /&gt;
:the compute_scores method returns a hash that stores the minimum, maximum and average score. We created a class ParticipantScore.rb that has attributes min, max and avg which store the minimum, maximum and average score of a particpant. This object could be used to maintain state as against an hash. Now the compute_score method returns an object of class ParticipantScore instead of an hash.&lt;/div&gt;</summary>
		<author><name>Srparadk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E804_spb&amp;diff=81159</id>
		<title>CSC/ECE 517 Fall 2013/oss E804 spb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E804_spb&amp;diff=81159"/>
		<updated>2013-10-30T19:19:57Z</updated>

		<summary type="html">&lt;p&gt;Srparadk: /* Created Database views */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Expertiza Code Refactoring&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
A way to query db models to return scores, without UI changes&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Project Description ==&lt;br /&gt;
&lt;br /&gt;
'''Classes:''' &lt;br /&gt;
:models/score.rb (159 lines)&lt;br /&gt;
:grades_controller.rb (241 lines)&lt;br /&gt;
&lt;br /&gt;
'''What needs to be done:''' &lt;br /&gt;
:This code is very slow, due to many factors.  Two of the most prominent are the fact that separate db queries are used for each rubric that has been filled out by anyone associated with the assignment; these queries are made sequentially while the HTML page is being written; and the fact that HTML for the whole page is generated, largely by controller methods, before anything is displayed.&lt;br /&gt;
:Need to refactor the score.rb model which contains complex methods.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Design Changes ==&lt;br /&gt;
&lt;br /&gt;
:The model scores.rb has only two methods that compute scores for the participants based on assignments and courses. But these methods have used hashes extensively to handle data. Also, the method get_total_score() makes many sequential queries to the database which increases the loading time for the page. These functions have logic which can be separated into two methods to make it more modular.&lt;br /&gt;
&lt;br /&gt;
=== Created Database views ===&lt;br /&gt;
&lt;br /&gt;
:Initially the method get_total_scores() was making multiple sequential queries to the database to calculate weighted_scores,sum_of_wieghts and max_question_score. Also, these queries were made to 4 different tables : questions,questionnaire,scores and question_types. This increases the time the page takes to load.&lt;br /&gt;
&lt;br /&gt;
:To reduce the loading time , we merged the multiple queries into a single query by implementing database views. We created a migration &amp;quot;CreateMyViews&amp;quot; that creates a view which has information from all the above 4 tables in one place. So now a single query on that view returns all the three values - weighted_scores,sum_of_wieghts and max_question_score.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Before implementing views:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:After implementing views:&lt;br /&gt;
&lt;br /&gt;
 questionnaireData = MyView.find_by_sql [&amp;quot;SELECT q1_max_question_score ,SUM(question_weight) as sum_of_weights,SUM(question_weight * s_score) as weighted_score FROM my_views WHERE q1_id = ? AND s_response_id = ?&amp;quot;,questions[0].questionnaire_id,response .id]&lt;br /&gt;
   weighted_score = questionnaireData[0].weighted_score.to_f&lt;br /&gt;
   sum_of_weights = questionnaireData[0].sum_of_weights.to_f&lt;br /&gt;
   max_question_score = questionnaireData[0].q1_max_question_score.to_f&lt;br /&gt;
&lt;br /&gt;
=== Separated functionality ===&lt;br /&gt;
:The get_total_scores function computes total scores and also has the code to check if a response is valid or invalid. This code is independent of computation of scores and can be separated into a separate function. We have created a function 'submission_valid?' to check if a given response is valid or not.&lt;br /&gt;
&lt;br /&gt;
=== Reduced the use of hash ===&lt;br /&gt;
:the get_total_scores function accepts a hash as a parameter, which can be avoided. We have refactored the method to accept three arguments instead of a hash. We had to change all the dependent classes that call this method.&lt;br /&gt;
:the compute_scores method returns a hash that stores the minimum, maximum and average score. We created a class ParticipantScore.rb that has attributes min, max and avg which store the minimum, maximum and average score of a particpant. This object could be used to maintain state as against an hash. Now the compute_score method returns an object of class ParticipantScore instead of an hash.&lt;/div&gt;</summary>
		<author><name>Srparadk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E804_spb&amp;diff=80544</id>
		<title>CSC/ECE 517 Fall 2013/oss E804 spb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E804_spb&amp;diff=80544"/>
		<updated>2013-10-30T05:11:08Z</updated>

		<summary type="html">&lt;p&gt;Srparadk: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Expertiza Code Refactoring&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
A way to query db models to return scores, without UI changes&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Project Description ==&lt;br /&gt;
&lt;br /&gt;
'''Classes:''' &lt;br /&gt;
:models/score.rb (159 lines)&lt;br /&gt;
:grades_controller.rb (241 lines)&lt;br /&gt;
&lt;br /&gt;
'''What needs to be done:''' &lt;br /&gt;
:This code is very slow, due to many factors.  Two of the most prominent are the fact that separate db queries are used for each rubric that has been filled out by anyone associated with the assignment; these queries are made sequentially while the HTML page is being written; and the fact that HTML for the whole page is generated, largely by controller methods, before anything is displayed.&lt;br /&gt;
:Need to refactor the score.rb model which contains complex methods.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Design Changes ==&lt;br /&gt;
&lt;br /&gt;
:The model scores.rb has only two methods that compute scores for the participants based on assignments and courses. But these methods have used hashes extensively to handle data. Also, the method get_total_score() makes many sequential queries to the database which increases the loading time for the page. These functions have logic which can be separated into two methods to make it more modular.&lt;br /&gt;
&lt;br /&gt;
=== Created Database views ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Separated functionality ===&lt;br /&gt;
:The get_total_scores function computes total scores and also has the code to check if a response is valid or invalid. This code is independent of computation of scores and can be separated into a separate function. We have created a function 'submission_valid?' to check if a given response is valid or not.&lt;br /&gt;
&lt;br /&gt;
=== Reduced the use of hash ===&lt;br /&gt;
:the get_total_scores function accepts a hash as a parameter, which can be avoided. We have refactored the method to accept three arguments instead of a hash. We had to change all the dependent classes that call this method.&lt;br /&gt;
:the compute_scores method returns a hash that stores the minimum, maximum and average score. We created a class ParticipantScore.rb that has attributes min, max and avg which store the minimum, maximum and average score of a particpant. This object could be used to maintain state as against an hash. Now the compute_score method returns an object of class ParticipantScore instead of an hash.&lt;/div&gt;</summary>
		<author><name>Srparadk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E804_spb&amp;diff=80535</id>
		<title>CSC/ECE 517 Fall 2013/oss E804 spb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E804_spb&amp;diff=80535"/>
		<updated>2013-10-30T04:56:56Z</updated>

		<summary type="html">&lt;p&gt;Srparadk: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Expertiza Code Refactoring&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
A way to query db models to return scores, without UI changes&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Project Description ==&lt;br /&gt;
&lt;br /&gt;
'''Classes:''' &lt;br /&gt;
:models/score.rb (159 lines)&lt;br /&gt;
:grades_controller.rb (241 lines)&lt;br /&gt;
&lt;br /&gt;
'''What needs to be done:''' &lt;br /&gt;
:This code is very slow, due to many factors.  Two of the most prominent are the fact that separate db queries are used for each rubric that has been filled out by anyone associated with the assignment; these queries are made sequentially while the HTML page is being written; and the fact that HTML for the whole page is generated, largely by controller methods, before anything is displayed.&lt;br /&gt;
:Need to refactor the score.rb model which contains complex methods.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Design Changes ==&lt;br /&gt;
&lt;br /&gt;
:The model scores.rb has only two methods that compute scores for the participants and scores. But these methods have used hashes extensively to handle data. Also, the method get_total_score() makes many sequential queries to the database which increases the loading time for the page. These functions have logic which can be separated into two methods to make it more modular.&lt;br /&gt;
&lt;br /&gt;
=== Create Database views ===&lt;/div&gt;</summary>
		<author><name>Srparadk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E804_spb&amp;diff=80533</id>
		<title>CSC/ECE 517 Fall 2013/oss E804 spb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E804_spb&amp;diff=80533"/>
		<updated>2013-10-30T04:44:05Z</updated>

		<summary type="html">&lt;p&gt;Srparadk: /* Project Description */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Expertiza Code Refactoring&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
A way to query db models to return scores, without UI changes&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Project Description ==&lt;br /&gt;
&lt;br /&gt;
'''Classes:''' &lt;br /&gt;
:models/score.rb (159 lines)&lt;br /&gt;
:grades_controller.rb (241 lines)&lt;br /&gt;
&lt;br /&gt;
'''What needs to be done:''' &lt;br /&gt;
:This code is very slow, due to many factors.  Two of the most prominent are the fact that separate db queries are used for each rubric that has been filled out by anyone associated with the assignment; these queries are made sequentially while the HTML page is being written; and the fact that HTML for the whole page is generated, largely by controller methods, before anything is displayed.&lt;br /&gt;
:Need to refactor the score.rb model which contains complex methods.&lt;/div&gt;</summary>
		<author><name>Srparadk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E804_spb&amp;diff=80532</id>
		<title>CSC/ECE 517 Fall 2013/oss E804 spb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E804_spb&amp;diff=80532"/>
		<updated>2013-10-30T04:43:16Z</updated>

		<summary type="html">&lt;p&gt;Srparadk: /* Project Description */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Expertiza Code Refactoring&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
A way to query db models to return scores, without UI changes&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Project Description ==&lt;br /&gt;
&lt;br /&gt;
'''Classes:''' &lt;br /&gt;
:models/score.rb (159 lines)&lt;br /&gt;
:grades_controller.rb (241 lines)&lt;br /&gt;
&lt;br /&gt;
'''What needs to be done:''' &lt;br /&gt;
:This code is very slow, due to many factors.  Two of the most prominent are the fact that separate db queries are used for each rubric that has been filled out by anyone associated with the assignment; these queries are made sequentially while the HTML page is being written; and the fact that HTML for the whole page is generated, largely by controller methods, before anything is displayed.&lt;br /&gt;
Need to refactor the score.rb model which contains complex methods.&lt;/div&gt;</summary>
		<author><name>Srparadk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E804_spb&amp;diff=80531</id>
		<title>CSC/ECE 517 Fall 2013/oss E804 spb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E804_spb&amp;diff=80531"/>
		<updated>2013-10-30T04:42:21Z</updated>

		<summary type="html">&lt;p&gt;Srparadk: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Expertiza Code Refactoring&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
A way to query db models to return scores, without UI changes&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Project Description ==&lt;br /&gt;
&lt;br /&gt;
'''Classes:''' &lt;br /&gt;
models/score.rb (159 lines)&lt;br /&gt;
grades_controller.rb (241 lines)&lt;br /&gt;
&lt;br /&gt;
'''What needs to be done:''' &lt;br /&gt;
This code is very slow, due to many factors.  Two of the most prominent are the fact that separate db queries are used for each rubric that has been filled out by anyone associated with the assignment; these queries are made sequentially while the HTML page is being written; and the fact that HTML for the whole page is generated, largely by controller methods, before anything is displayed.&lt;br /&gt;
Need to refactor the score.rb model which contains complex methods.&lt;/div&gt;</summary>
		<author><name>Srparadk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E804_spb&amp;diff=80529</id>
		<title>CSC/ECE 517 Fall 2013/oss E804 spb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E804_spb&amp;diff=80529"/>
		<updated>2013-10-30T04:40:25Z</updated>

		<summary type="html">&lt;p&gt;Srparadk: Created page with &amp;quot;== Introduction ==  A way to query db models to return scores, without UI changes   == Project Description ==  '''Classes:''' &amp;lt;br&amp;gt;models/score.rb (159 lines)                &amp;lt;br&amp;gt;g...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
A way to query db models to return scores, without UI changes&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Project Description ==&lt;br /&gt;
&lt;br /&gt;
'''Classes:''' &amp;lt;br&amp;gt;models/score.rb (159 lines)&lt;br /&gt;
               &amp;lt;br&amp;gt;grades_controller.rb (241 lines)&lt;br /&gt;
&lt;br /&gt;
'''What needs to be done:''' &amp;lt;br&amp;gt;This code is very slow, due to many factors.  Two of the most prominent are the fact that separate db queries are used for each rubric that has been filled out by anyone associated with the assignment; these queries are made sequentially while the HTML page is being written; and the fact that HTML for the whole page is generated, largely by controller methods, before anything is displayed.&lt;br /&gt;
.Need to refactor the score.rb model which contains complex methods.&lt;br /&gt;
.&lt;/div&gt;</summary>
		<author><name>Srparadk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013&amp;diff=80528</id>
		<title>CSC/ECE 517 Fall 2013</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013&amp;diff=80528"/>
		<updated>2013-10-30T04:26:37Z</updated>

		<summary type="html">&lt;p&gt;Srparadk: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* [[ CSC/ECE 517 Fall 2012/ch1 1w23 ph ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w30 nn]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w21 w]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w01 aj]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w24 nv]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w29 rkld]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w25 aras]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w30 ps]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w19 rj]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w18 bs]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w17 pk]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w22 ss]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w12 vn]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w14 st]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w08 cc]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w10 ga ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w26 as ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w27 ma ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w13 aa ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w11 sv ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w07 d ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w20 gq ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w03 ss ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w28 nm ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w02 pp ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1  1w6 zs ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1  1w04 y ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w05 st ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w09 hs ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w32 av ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w48 x ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w43 av]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w46 ka]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w33 aa]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w35 sa ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w39 as ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w31 vm ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w43 sm ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w44 s ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w47 ka ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w34 fs ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w40 ao ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/oss fmv ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/oss vna ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/oss paa ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/oss mapFeeds ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/oss ssp ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch2 0e808 nsv ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/oss aoa ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/oss cmh ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/oss ans ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/oss ssv]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/oss E818 mra ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/oss SocialMediaFeeds ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/oss E811 syn ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/oss E804 spb ]]&lt;/div&gt;</summary>
		<author><name>Srparadk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w18_bs&amp;diff=77531</id>
		<title>CSC/ECE 517 Fall 2013/ch1 1w18 bs</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w18_bs&amp;diff=77531"/>
		<updated>2013-09-18T03:46:48Z</updated>

		<summary type="html">&lt;p&gt;Srparadk: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Internationalization in Rails&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
:In general when we start a conversation, the first default language of communication we use is English, but if the other person is not familiar with English we try and translate our dialogue in a language that the person is familiar with. Similarly whenever we write a program or a document we write it in English by default. But what if someone who is not familiar with English wants to read your program or code? The simple solution is that we translate program or code into a language that the person is familiar with. And for this, we use a term called internationalization.&lt;br /&gt;
&lt;br /&gt;
:Internationalization is a way by which we can view an application in various languages without actually making changes to the code of the application. This saves us a lot of time and effort, as we don’t have to write or edit the same code or document in all the copies.&lt;br /&gt;
&lt;br /&gt;
:Internationalization has an acronym, rather more of a numeronym ,which is i18n where the number 18 represents the number of letters between the first and last letters in the word internationalization.&lt;br /&gt;
&lt;br /&gt;
== Aspects to consider in Internationalization ==&lt;br /&gt;
&lt;br /&gt;
:Now when we are to change our application according to a particular language or a region , we need to keep in mind numerous points that are important, implicit, particular or sensitive to that language or region. Like for example when we take a language into consideration for which our application needs to be translated, we need to consider the spoken and written aspects of that language. Also, there might be a case when we have the same language but it differs from one region to other. For this we need to keep in mind the typical change in the use of words, grammar and symbol for each region that uses the same language. Our application must also provide support for the varied writing conventions that differ from a language to another language or from one region to another.&lt;br /&gt;
&lt;br /&gt;
:Below are the examples of the points we need to keep in mind while we provide internationalization to our application :&lt;br /&gt;
&lt;br /&gt;
* Language :&lt;br /&gt;
&lt;br /&gt;
:Here the i18n support to an application needs to provide the character encoding keeping in mind the following points:&lt;br /&gt;
&lt;br /&gt;
#The written language differs. For example most of the languages like English, French, German follow a script that can have inputs from a standard keyboard. But there are other languages like Hindi, Marathi, Sanskrit that follow a script called Devnagri and this cannot be directly typed in from a standard keyboard. So if we have to provide support for these languages we need to support the translation of the characters used in these scripts.&lt;br /&gt;
#The way we write also differs and needs to included in our i18n support. For example most of the languages follow a left-right direction while writing but some languages like Urdu tend to follow a right-left direction.&lt;br /&gt;
#The numbering symbols also vary from language to language. So when we display or accept any text with numbers, we must have i18n to support this mapping.&lt;br /&gt;
#The languages also differ in the use of grammar and structure of the sentences.For example the grammar rules and structure formation in English is way different than the one followed by another language like Sanskrit.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Culture and Writing Conventions:&lt;br /&gt;
&lt;br /&gt;
:Even if the language with the same characters and grammar is used, the use of the language , the symbols , the way of writing and many other things change with change in the region.&lt;br /&gt;
:Following are some of the examples:&lt;br /&gt;
&lt;br /&gt;
#There are some cultures that have some regulations about having a middle name as father’s name but other cultures don’t necessary include the middle name.&lt;br /&gt;
#There might be cases when there are different names or terminologies used in different cultures for the same purpose. For example, to identify a citizen uniquely US has the system of SSN while India is in the process of implementing this by using the term as Aadhar number.&lt;br /&gt;
#Another example of difference in the writing convention can be taken as that of a postal code. Some countries have 6 digit postal codes while others have 5.&lt;br /&gt;
#There is a difference in the use of many other things like the currency(like INR,dollars,Euro) used, the symbols(€,$,₹) used , the units in which the weights , temperature are measured. Another example could be the use of lakhs , crores for mentioning any financial figures in some countries while others use millions, billions.&lt;br /&gt;
#There could also be a difference in the formats used for a same thing. For example the format of writing dates and times vary from one region to another.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* We also have to be careful that we cover all the sensitive topics and issues particular to a language or region.&lt;br /&gt;
&lt;br /&gt;
:Similarly there are many other factors that we need to take care of when we support internationalization for a particular language in a particular region.&lt;br /&gt;
&lt;br /&gt;
= Internationalization in Rails =&lt;br /&gt;
&lt;br /&gt;
:Internationalization support was extended from Rails version 2.2. So in order to internationalize a rails application, it has to be migrated to Rails 2.2 or above. Every static string in the Rails framework e.g. Active Record validation messages, time and date formats, have been internationalized.&lt;br /&gt;
&lt;br /&gt;
:Following needs to be done in order to internationalize a rails application:&lt;br /&gt;
:#Ensure support for internationalization by migrating to appropriate version of rails if needed.&lt;br /&gt;
:#Tell rails where to find the appropriate translations files&lt;br /&gt;
:#Tell rails how to switch locales&lt;br /&gt;
&lt;br /&gt;
::YAML (.yml) or plain Ruby (.rb) files are used for storing translations.&lt;br /&gt;
&lt;br /&gt;
== History ==&lt;br /&gt;
&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Ruby version !! Features added&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100pt&amp;quot;| [http://guides.rubyonrails.org/2_2_release_notes.html Ruby 2.2]    || Internationalization support was extended from this version of Rails.&lt;br /&gt;
|-&lt;br /&gt;
| [http://guides.rubyonrails.org/2_3_release_notes.html Ruby 2.3]    || Additional feature for Localized Views was added in this version. The view files were rendered with an extension of the locale name.I18n#available_locales and I18n::SimpleBackend#available_locales is available to retrieve an array of available locales.&lt;br /&gt;
|-&lt;br /&gt;
| [http://guides.rubyonrails.org/3_0_release_notes.html Ruby 3.0]    || Some additional features were added to the I18n gem for speed improvements like default translations for attributes,automatic pull for translations on form submit, etc.&lt;br /&gt;
|-&lt;br /&gt;
| [http://guides.rubyonrails.org/3_1_release_notes.html Ruby 3.1]    || I18n namespace lookup support removed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Ways to configure Internationalization in Rails ==&lt;br /&gt;
&lt;br /&gt;
:We can set up a rails application to support internationalization in a number of ways. Below are the various ways to configure our rails application for internationalization.&lt;br /&gt;
&lt;br /&gt;
#'''Configure the I18n module:'''&amp;lt;br&amp;gt;Rails adds all .rb and .yml files from the config/locales directory to your translations load path, automatically. This is the default setting provided by the [https://github.com/svenfuchs/i18n I18n gem]. In order to override this setting we have to make changes in the application.rb files that have instructions on how to add locales from another directory and how to set a different default locale.&amp;lt;br&amp;gt;config.i18n.load_path += Dir[Rails.root.join('mydir', 'locales', '*.{rb,yml}').to_s]&amp;lt;br&amp;gt;config.i18n.default_locale = :es&lt;br /&gt;
#'''Custom I18n Configuration Setup:'''&amp;lt;br&amp;gt;Optionally, the above code can be placed anywhere in the application preferably in initializers.&lt;br /&gt;
#'''Setting and passing locale:'''&amp;lt;br&amp;gt;The above two steps help setup a default locale throughout the application. But in case we have to provide our application in different languages, we can setup the application default locale in the application.rb and then set the locale using the applicationController before_action. We can then pass the locale we want as a query param for example-  study.com/books?locale=es&lt;br /&gt;
#'''Setting the locale from the domain name:'''&amp;lt;br&amp;gt;Similar to option 3 but instead of passing the locale as a query param, the locale is a part of the domain name itself. For example- study.es. You can implement it like this in your [http://api.rubyonrails.org/classes/ActionController/Base.html ApplicationController] before_action&lt;br /&gt;
#'''Setting the locale from the URL params:'''&amp;lt;br&amp;gt;&lt;br /&gt;
##This can be a tedious task as we have to pass the locale on each request. &lt;br /&gt;
##Rails provides us an alternative for &amp;quot;centralizing dynamic decisions about the URLs&amp;quot; in its ApplicationController#default_url_options and helper methods are dependent on it (by implementing/overriding this method). This will now automatically include the locale param in the query string&lt;br /&gt;
##We can also set the locale in the URL route. For example- study.com/es/books. This is achievable by using over-riding default_url_options. You just have to set up your routes with scoping option in routes.rb. &lt;br /&gt;
#'''Setting the locale from client supplied information:'''&amp;lt;br&amp;gt;This can be done in 3 ways&lt;br /&gt;
##Using the default locale of the client browser&lt;br /&gt;
##Using client location to select the locale&lt;br /&gt;
##Saving the users choice of locale as a part of user profile&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Internationalizing Rails application ==&lt;br /&gt;
&lt;br /&gt;
:After your application is prepared for internationalization, we need to use the feature in our application. &lt;br /&gt;
:This can be done in the following ways:&lt;br /&gt;
&lt;br /&gt;
1. '''Adding Translations:'''&lt;br /&gt;
:In order to internationalize rails code, replace the strings with calls to  the ‘t’ helper.&amp;lt;br&amp;gt;For example: &lt;br /&gt;
 class HelloWorld &lt;br /&gt;
  def sayHello&lt;br /&gt;
    puts t(:hello_world)&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;%=t :hello_world %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:The helper method t also catches missing translations and displays appropriate error message.&lt;br /&gt;
 &amp;lt;nowiki /&amp;gt;# config/locales/en.yml&lt;br /&gt;
 en: hello_world: Hello world!&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki /&amp;gt;# config/locales/es.yml&lt;br /&gt;
 es: hello_world: hola mundo&lt;br /&gt;
&lt;br /&gt;
2. '''Passing variables to translation:'''&lt;br /&gt;
:You can use variables in the translation messages and pass their values from the view.&lt;br /&gt;
 en:&lt;br /&gt;
 portal: &amp;quot;Mypack&amp;quot;&lt;br /&gt;
   university:&lt;br /&gt;
    ncsu:&lt;br /&gt;
    description: ! 'NCSU student information is accessed on %{portal_name}’ &lt;br /&gt;
&lt;br /&gt;
 t('.description', portal_name: t(‘portal’))&lt;br /&gt;
&lt;br /&gt;
3. '''Adding date/ time formats:'''&lt;br /&gt;
:OK! Now let's add a timestamp to the view, so we can demo the date/time localization feature as well. To localize the time format you pass the Time object to I18n.l or (preferably) use ‘l’ helper. You can pick a format by passing the :format option — by default the :default format is used.&lt;br /&gt;
:In the view file:&lt;br /&gt;
 &amp;lt;%= l Time.now, format: :short %&amp;gt;&lt;br /&gt;
:In the yml file:&lt;br /&gt;
  es:&lt;br /&gt;
   time:&lt;br /&gt;
     formats:&lt;br /&gt;
       short: &amp;quot; Son las %H&amp;quot;&lt;br /&gt;
&lt;br /&gt;
4. '''Inflection rules for locales other than english:'''&lt;br /&gt;
:Rails 4.0 provides a feature to define inflection rules (singularization and pluralization)  in config/initializers/inflections.rb. &lt;br /&gt;
&lt;br /&gt;
5. '''Localized views:'''&lt;br /&gt;
:For static websites available in different languages or for large static content, localized views is a useful feature. This feature enables having separate view file for different locales. For example for default locale we can have show.html.erb file while for Spanish we can have show.es.html.erb. Thus we don’t need to maintain long .yml files for each supported locale for long static pages.&lt;br /&gt;
&lt;br /&gt;
== Internationalization Features ==&lt;br /&gt;
&lt;br /&gt;
1. '''Using Different Backends:'''&lt;br /&gt;
:The i18n provides a [http://www.ruby-doc.org/gems/docs/s/synergy_russian-0.2.8/I18n/Backend/Simple.html simple backend] by default. We can change the backend to an active records backend or chain multiple backends as per the requirements of our application. I18n gem also provides cache, fallback and pluralization feature for the backends.&lt;br /&gt;
&lt;br /&gt;
2. '''Pluralization:'''&lt;br /&gt;
:Different languages have different rules for pluralization. Thus, the I18n API provides a flexible pluralization feature.&lt;br /&gt;
&lt;br /&gt;
3. '''Fallbacks:'''&lt;br /&gt;
:In case translation for a certain  locale is missing we can define fallback chain for the locales.&lt;br /&gt;
:For example we can define a fallback chain of the form &lt;br /&gt;
 :'en-CA' =&amp;gt; :'en-US', :'en-US' =&amp;gt; :en, :de =&amp;gt; :en &lt;br /&gt;
&lt;br /&gt;
:if the translation for en-CA is missing rails looks for en-US , if en-US is missing it then looks for en and so on.&lt;br /&gt;
&lt;br /&gt;
4. '''Cascading lookups:'''&lt;br /&gt;
:If a given key is not found, it is broken and a lookup is performed for the remaining portion of the key before finally falling back to the defaults.&lt;br /&gt;
&lt;br /&gt;
5. '''Translation symlinks:'''&lt;br /&gt;
:A key can be a value for another key.&lt;br /&gt;
:Example:&lt;br /&gt;
 person: ‘ash’&lt;br /&gt;
 student: :person&lt;br /&gt;
 employee: :person&lt;br /&gt;
&lt;br /&gt;
:Ash can be an employee or a student. Each key represents the same value.&lt;br /&gt;
&lt;br /&gt;
6. '''Translation procs:'''&lt;br /&gt;
:I18n gem allows writing translation logic in the translation lookup process.&lt;br /&gt;
:For example:&lt;br /&gt;
 :en&lt;br /&gt;
  	:addressing =&amp;gt; lambda { |values|&lt;br /&gt;
 		person=values[:person]&lt;br /&gt;
 		address=person.male? ?  “Sir” : “Madam”&lt;br /&gt;
 	“Hello, #{person.address}”&lt;br /&gt;
 &lt;br /&gt;
 t(:addressing , :person =&amp;gt; mary)&lt;br /&gt;
&lt;br /&gt;
= Advantages of Internationalization = &lt;br /&gt;
&lt;br /&gt;
#Internationalization opens up a whole new market for applications. For example, consider a website which has support for internationalization and because of that it can be displayed in a number of languages. This opens a lot of new markets, business opportunities and a large number of potential customers.&lt;br /&gt;
#With the help of the internationalization gem, the application code has been simplified.&lt;br /&gt;
#The maintenance of the code is also made easy.  Also, the steps to add support to a new language are quite simple. &lt;br /&gt;
#Internationalization in rails(i18n gem) provides a variety of ways to incorporate internationalization in our application. This makes it easier for the developer to adopt a method that suits his application. For example, for a static application we can we one configuration technique and say for a dynamic application we can follow another configuration method for internationalization.&lt;br /&gt;
&lt;br /&gt;
= Internationalization in other languages =&lt;br /&gt;
== PHP ==&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
:In PHP, we need to install/enable extensions to support [http://devzone.zend.com/1500/internationalization-in-php-53/ internationalization](not required with PHP 5.3.0 version). For building the internationalization tool we must have  ICU library (v 3.6 or more). &lt;br /&gt;
:The internationalization in PHP is provided by modules which are built with the internationalization extension. PHP applies i18n in one of the following ways:&lt;br /&gt;
#'''Using Object-Oriented API :''' &amp;lt;br&amp;gt;This makes of the object-oriented API provided by the modules. This method represents the modules in the form of classes.&lt;br /&gt;
#'''Using Procedural API :''' &amp;lt;br&amp;gt;This makes use of the procedural API provided by the modules. This method represents the modules in the form of a group of functions.&lt;br /&gt;
:Note: Each module provides both of the above API’s.&lt;br /&gt;
:Each of these modules provide different functionality of internationalization. For example PHP has modules like:&lt;br /&gt;
&lt;br /&gt;
#'''Locale''' —  This mainly deals with breaking and assembling of strings from components and displaying them in a specified locale.&lt;br /&gt;
#'''Collator''' —  This maily deals with comparison and sorting of strings according to the rules of the specified locale.&lt;br /&gt;
#'''Number formatter''' — This mainly deals with formatting number in a specific way according to a locale and also parses textual representations of numbers.&lt;br /&gt;
#'''Date formatter''' —  This formats dates in accordance to the specified locale.&lt;br /&gt;
:and many more…&lt;br /&gt;
&lt;br /&gt;
=== Comparison with Ruby ===&lt;br /&gt;
&lt;br /&gt;
#Internationalization in PHP is a bit easy as compared to ruby. Because the way to implement internationalization is very similar to creating an object of a class and then using one of the functions of the classes. And hence the programmer is familiar with the syntax.&lt;br /&gt;
#Whenever we need to add more features to internationalization, in PHP we just have to add a module to the internationalization extension.&lt;br /&gt;
&lt;br /&gt;
== Java ==&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
Java extends a built-in support for [http://docs.oracle.com/javase/tutorial/i18n/ internationalization].&lt;br /&gt;
&lt;br /&gt;
* In java, we do not set a global variable for locale. We set a default locale and assign a locale separately to each object as and when needed.&lt;br /&gt;
* Lookup of translations is made in an efficient way with support for fallbacks, interpolation etc. The translations are stored in the [http://blog.lingohub.com/developers/2013/03/resource-file-formats-properties-files-comments/ .properties] file which contains key-value pairs.&lt;br /&gt;
* The ResourceBundle class is responsible for loading locale specific objects.&lt;br /&gt;
* It also supports formatting of numbers, currencies, date and time and messages according to the locale.&lt;br /&gt;
* The Java programming language provides support to handle text in a locale-independent manner.&lt;br /&gt;
* Java also provides support for Internationalization for domain name.&lt;br /&gt;
&lt;br /&gt;
=== Comparison with Ruby ===&lt;br /&gt;
&lt;br /&gt;
# Java code for internationalization may seem complex as compared to incorporating internationalization in ruby.&lt;br /&gt;
# Java does not extend any special support for pluralisation But we can pluralize our strings by breaking them and storing them with separate keys. Java internationalization is much more advanced then ruby internationalization.&lt;br /&gt;
# Java internationalization provides a lot of features as opposed to ruby. Ruby at the most basic level cares only about looking up translations,formating date/time and currency. Java supports the following internationalization aspects looking up translations,formating date/time and currency, time zones, calendar systems, collation, character encoding, etc.&lt;br /&gt;
&lt;br /&gt;
= See Also =&lt;br /&gt;
http://rubylearning.com/blog/2012/07/24/minimal-i18n-with-rails-3-2/ &amp;lt;br&amp;gt;&lt;br /&gt;
http://www.artweb-design.de/2009/7/19/experimental-extensions-in-i18n-pluralization-fallbacks-gettext-cache-and-chain &amp;lt;br&amp;gt;&lt;br /&gt;
http://asciicasts.com/episodes/256-i18n-backends &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
http://guides.rubyonrails.org/v2.3.11/i18n.html &amp;lt;br&amp;gt;&lt;br /&gt;
http://blog.lingohub.com/developers/2013/08/internationalization-for-ruby-i18n-gem/ &amp;lt;br&amp;gt;&lt;br /&gt;
http://vimeo.com/12665914 &amp;lt;br&amp;gt;&lt;br /&gt;
http://blog.lingohub.com/developers/2013/08/i18n-gem-advanced-features-ruby-rails-internationalization/ &amp;lt;br&amp;gt;&lt;br /&gt;
http://en.wikipedia.org/wiki/Internationalization_and_localization &amp;lt;br&amp;gt;&lt;br /&gt;
http://devzone.zend.com/1500/internationalization-in-php-53/  &amp;lt;br&amp;gt;&lt;br /&gt;
http://www.php.net/manual/en/intro.intl.php &amp;lt;br&amp;gt;	&lt;br /&gt;
http://www.php.net/manual/en/intl.requirements.php &amp;lt;br&amp;gt;&lt;br /&gt;
http://www.php.net/manual/en/intl.installation.php &amp;lt;br&amp;gt;&lt;br /&gt;
http://www.php.net/manual/en/intl.configuration.php &amp;lt;br&amp;gt;&lt;br /&gt;
http://www.php.net/manual/en/intl.examples.basic.php &amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Srparadk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w18_bs&amp;diff=76950</id>
		<title>CSC/ECE 517 Fall 2013/ch1 1w18 bs</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w18_bs&amp;diff=76950"/>
		<updated>2013-09-17T19:00:40Z</updated>

		<summary type="html">&lt;p&gt;Srparadk: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Internationalization in Rails&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
:In general when we start a conversation, the first default language of communication we use is English, but if the other person is not familiar with English we try and translate our dialogue in a language that the person is familiar with. Similarly whenever we write a program or a document we write it in English by default. But what if someone who is not familiar with English wants to read your program or code? The simple solution is that we translate program or code into a language that the person is familiar with. And for this, we use a term called internationalization.&lt;br /&gt;
&lt;br /&gt;
:Internationalization is a way by which we can view an application in various languages without actually making changes to the code of the application. This saves us a lot of time and effort, as we don’t have to write or edit the same code or document in all the copies.&lt;br /&gt;
&lt;br /&gt;
:Internationalization has an acronym, rather more of a numeronym ,which is i18n where the number 18 represents the number of letters between the first and last letters in the word internationalization.&lt;br /&gt;
&lt;br /&gt;
== Aspects to consider in Internationalization ==&lt;br /&gt;
&lt;br /&gt;
:Now when we are to change our application according to a particular language or a region , we need to keep in mind numerous points that are important, implicit, particular or sensitive to that language or region. Like for example when we take a language into consideration for which our application needs to be translated, we need to consider the spoken and written aspects of that language. Also, there might be a case when we have the same language but it differs from one region to other. For this we need to keep in mind the typical change in the use of words, grammar and symbol for each region that uses the same language. Our application must also provide support for the varied writing conventions that differ from a language to another language or from one region to another.&lt;br /&gt;
&lt;br /&gt;
:Below are the examples of the points we need to keep in mind while we provide internationalization to our application :&lt;br /&gt;
&lt;br /&gt;
* Language :&lt;br /&gt;
&lt;br /&gt;
:Here the i18n support to an application needs to provide the character encoding keeping in mind the following points:&lt;br /&gt;
&lt;br /&gt;
#The written language differs. For example most of the languages like English, French, German follow a script that can have inputs from a standard keyboard. But there are other languages like Hindi, Marathi, Sanskrit that follow a script called Devnagri and this cannot be directly typed in from a standard keyboard. So if we have to provide support for these languages we need to support the translation of the characters used in these scripts.&lt;br /&gt;
#The way we write also differs and needs to included in our i18n support. For example most of the languages follow a left-right direction while writing but some languages like Urdu tend to follow a right-left direction.&lt;br /&gt;
#The numbering symbols also vary from language to language. So when we display or accept any text with numbers, we must have i18n to support this mapping.&lt;br /&gt;
#The languages also differ in the use of grammar and structure of the sentences.For example the grammar rules and structure formation in English is way different than the one followed by another language like Sanskrit.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Culture and Writing Conventions:&lt;br /&gt;
&lt;br /&gt;
:Even if the language with the same characters and grammar is used, the use of the language , the symbols , the way of writing and many other things change with change in the region.&lt;br /&gt;
:Following are some of the examples:&lt;br /&gt;
&lt;br /&gt;
#There are some cultures that have some regulations about having a middle name as father’s name but other cultures don’t necessary include the middle name.&lt;br /&gt;
#There might be cases when there are different names or terminologies used in different cultures for the same purpose. For example, to identify a citizen uniquely US has the system of SSN while India is in the process of implementing this by using the term as Aadhar number.&lt;br /&gt;
#Another example of difference in the writing convention can be taken as that of a postal code. Some countries have 6 digit postal codes while others have 5.&lt;br /&gt;
#There is a difference in the use of many other things like the currency(like INR,dollars,Euro) used, the symbols(€,$,₹) used , the units in which the weights , temperature are measured. Another example could be the use of lakhs , crores for mentioning any financial figures in some countries while others use millions, billions.&lt;br /&gt;
#There could also be a difference in the formats used for a same thing. For example the format of writing dates and times vary from one region to another.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* We also have to be careful that we cover all the sensitive topics and issues particular to a language or region.&lt;br /&gt;
&lt;br /&gt;
:Similarly there are many other factors that we need to take care of when we support internationalization for a particular language in a particular region.&lt;br /&gt;
&lt;br /&gt;
= Internationalization in Rails =&lt;br /&gt;
&lt;br /&gt;
:Internationalization support was extended from Rails version 2.2. So in order to internationalize a rails application, it has to be migrated :to Rails 2.2 or above. Every static string in the Rails framework — e.g. Active Record validation messages, time and date formats — have :been internationalized.&lt;br /&gt;
&lt;br /&gt;
:Following needs to be done in order to internationalize a rails application:&lt;br /&gt;
:#Ensure support for internationalization by migrating to appropriate version of rails if needed.&lt;br /&gt;
:#Tell rails where to find the appropriate translations files&lt;br /&gt;
:#Tell rails how to switch locales&lt;br /&gt;
&lt;br /&gt;
::YAML (.yml) or plain Ruby (.rb) files are used for storing translations.&lt;br /&gt;
&lt;br /&gt;
== History ==&lt;br /&gt;
&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100pt&amp;quot;| Ruby 2.2    || Internationalization support was extended from this version of Rails.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 2.3    || Additional feature for Localized Views was added in this version. The view files were rendered with an extension of the locale name.I18n#available_locales and I18n::SimpleBackend#available_locales is available to retrieve an array of available locales.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 3.0    || Some additional features were added to the I18n gem for speed improvements like default translations for attributes,automatic pull for translations on form submit, etc.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 3.1    || I18n namespace lookup support removed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Ways to configure Internationalization in Rails ==&lt;br /&gt;
&lt;br /&gt;
:We can set up a rails application to support internationalization in a number of ways. Below are the various ways to configure our rails application for internationalization.&lt;br /&gt;
&lt;br /&gt;
#'''Configure the I18n module:'''&amp;lt;br&amp;gt;Rails adds all .rb and .yml files from the config/locales directory to your translations load path, automatically. This is the default setting provided by the [https://github.com/svenfuchs/i18n I18n gem]. In order to override this setting we have to make changes in the application.rb files that have instructions on how to add locales from another directory and how to set a different default locale.&lt;br /&gt;
#'''Custom I18n Configuration Setup:'''&amp;lt;br&amp;gt;Optionally, the above code can be placed anywhere in the application preferably in initializers.&lt;br /&gt;
#'''Setting and passing locale:'''&amp;lt;br&amp;gt;The above two steps help setup a default locale throughout the application. But in case we have to provide our application in different languages, we can setup the application default locale in the application.rb and then set the locale using the application-controller.rb before_action. We can then pass the locale we want as a query param for example http://study.com/books?locale=es&lt;br /&gt;
#'''Setting the locale from the domain name:'''&amp;lt;br&amp;gt;Similar to option 3 but instead of passing the locale as a query param, the locale is a part of the domain name itself. Example http://study.es&lt;br /&gt;
::You can implement it like this in your ApplicationController before_action&lt;br /&gt;
#'''Setting the locale from the URL params:'''&amp;lt;br&amp;gt;&lt;br /&gt;
##This can be a tedious task as we have to pass the locale on each request. &lt;br /&gt;
##Rails provides us an alternative for &amp;quot;centralizing dynamic decisions about the URLs&amp;quot; in its ApplicationController#default_url_options and helper methods are dependent on it (by implementing/overriding this method). This will now automatically include the locale param in the query string&lt;br /&gt;
##We can also set the locale in the URL route. For example -http://study.com/es/books .This is achievable by using over-riding default_url_options. You just have to set up your routes with scoping option in routes.rb. &lt;br /&gt;
#'''Setting the locale from client supplied information:'''&amp;lt;br&amp;gt;This can be done in 3 ways&lt;br /&gt;
##Using the default locale of the client browser&lt;br /&gt;
##Using client location to select the locale&lt;br /&gt;
##Saving the users choice of locale as a part of user profile&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Internationalizing Rails application ==&lt;br /&gt;
&lt;br /&gt;
:After your application is prepared for internationalization, we need to use the feature in our application. &lt;br /&gt;
:This can be done in the following ways:&lt;br /&gt;
&lt;br /&gt;
1. '''Adding Translations:'''&lt;br /&gt;
:In order to internationalize rails code, replace the strings with calls to  the ‘t’ helper.&amp;lt;br&amp;gt;For example: &lt;br /&gt;
 class HelloWorld &lt;br /&gt;
  def sayHello&lt;br /&gt;
    puts t(:hello_world)&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;%=t :hello_world %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:The helper method t also catches missing translations and displays appropriate error message.&lt;br /&gt;
 &amp;lt;nowiki /&amp;gt;# config/locales/en.yml&lt;br /&gt;
 en: hello_world: Hello world!&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki /&amp;gt;# config/locales/es.yml&lt;br /&gt;
 es: hello_world: hola mundo&lt;br /&gt;
&lt;br /&gt;
2. '''Passing variables to translation:'''&lt;br /&gt;
:You can use variables in the translation messages and pass their values from the view.&lt;br /&gt;
 en:&lt;br /&gt;
 portal: &amp;quot;Mypack&amp;quot;&lt;br /&gt;
   university:&lt;br /&gt;
    ncsu:&lt;br /&gt;
    description: ! 'NCSU student information is accessed on %{portal_name}’ &lt;br /&gt;
&lt;br /&gt;
 t('.description', portal_name: t(‘portal’))&lt;br /&gt;
&lt;br /&gt;
3. '''Adding date/ time formats:'''&lt;br /&gt;
:OK! Now let's add a timestamp to the view, so we can demo the date/time localization feature as well. To localize the time format you pass the Time object to I18n.l or (preferably) use ‘l’ helper. You can pick a format by passing the :format option — by default the :default format is used.&lt;br /&gt;
:In the view file:&lt;br /&gt;
 &amp;lt;%= l Time.now, format: :short %&amp;gt;&lt;br /&gt;
:In the yml file:&lt;br /&gt;
  es:&lt;br /&gt;
   time:&lt;br /&gt;
     formats:&lt;br /&gt;
       short: &amp;quot; Son las %H&amp;quot;&lt;br /&gt;
&lt;br /&gt;
4. '''Inflection rules for locales other than english:'''&lt;br /&gt;
:Rails 4.0 provides a feature to define inflection rules (singularization and pluralization)  in config/initializers/inflections.rb. &lt;br /&gt;
&lt;br /&gt;
5. '''Localized views:'''&lt;br /&gt;
:For static websites available in different languages or for large static content, localized views is a useful feature. This feature enables having separate view file for different locales. For example for default locale we can have show.html.erb file while for Spanish we can have show.es.html.erb. Thus we don’t need to maintain long .yml files for each supported locale for long static pages.&lt;br /&gt;
&lt;br /&gt;
== Internationalization Features ==&lt;br /&gt;
&lt;br /&gt;
1. '''Using Different Backends:'''&lt;br /&gt;
:The i18n provides a [http://www.ruby-doc.org/gems/docs/s/synergy_russian-0.2.8/I18n/Backend/Simple.html simple backend] by default. We can change the backend to an active records backend or chain multiple backends as per the requirements of our application. I18n gem also provides cache, fallback and pluralization feature for the backends.&lt;br /&gt;
&lt;br /&gt;
2. '''Pluralization:'''&lt;br /&gt;
:Different languages have different rules for pluralization. Thus, the I18n API provides a flexible pluralization feature.&lt;br /&gt;
&lt;br /&gt;
3. '''Fallbacks:'''&lt;br /&gt;
:In case translation for a certain  locale is missing we can define fallback chain for the locales.&lt;br /&gt;
:For example we can define a fallback chain of the form &lt;br /&gt;
 :'en-CA' =&amp;gt; :'en-US', :'en-US' =&amp;gt; :en, :de =&amp;gt; :en &lt;br /&gt;
&lt;br /&gt;
:if the translation for en-CA is missing rails looks for en-US , if en-US is missing it then looks for en and so on.&lt;br /&gt;
&lt;br /&gt;
4. '''Cascading lookups:'''&lt;br /&gt;
:If a given key is not found, it is broken and a lookup is performed for the remaining portion of the key before finally falling back to the defaults.&lt;br /&gt;
&lt;br /&gt;
5. '''Translation symlinks:'''&lt;br /&gt;
:A key can be a value for another key.&lt;br /&gt;
:Example:&lt;br /&gt;
 person: ‘ash’&lt;br /&gt;
 student: :person&lt;br /&gt;
 employee: :person&lt;br /&gt;
&lt;br /&gt;
:Ash can be an employee or a student. Each key represents the same value.&lt;br /&gt;
&lt;br /&gt;
6. '''Translation procs:'''&lt;br /&gt;
:I18n gem allows writing translation logic in the translation lookup process.&lt;br /&gt;
:For example:&lt;br /&gt;
 :en&lt;br /&gt;
  	:addressing =&amp;gt; lambda { |values|&lt;br /&gt;
 		person=values[:person]&lt;br /&gt;
 		address=person.male? ?  “Sir” : “Madam”&lt;br /&gt;
 	“Hello, #{person.address}”&lt;br /&gt;
 &lt;br /&gt;
 t(:addressing , :person =&amp;gt; mary)&lt;br /&gt;
&lt;br /&gt;
= Advantages of Internationalization = &lt;br /&gt;
&lt;br /&gt;
#Internationalization opens up a whole new market for applications. For example, consider a website which has support for internationalization and because of that it can be displayed in a number of languages. This opens a lot of new markets, business opportunities and a large number of potential customers.&lt;br /&gt;
#With the help of the internationalization gem, the application code has been simplified.&lt;br /&gt;
#The maintenance of the code is also made easy.  Also, the steps to add support to a new language are quite simple. &lt;br /&gt;
#Internationalization in rails(i18n gem) provides a variety of ways to incorporate internationalization in our application. This makes it easier for the developer to adopt a method that suits his application. For example, for a static application we can we one configuration technique and say for a dynamic application we can follow another configuration method for internationalization.&lt;br /&gt;
&lt;br /&gt;
= Internationalization in PHP, Java =&lt;br /&gt;
== Internationalization in PHP ==&lt;br /&gt;
&lt;br /&gt;
:In PHP, we need to install/enable extensions to support internationalization(not required with PHP 5.3.0 version). For building the internationalization tool we must have  ICU library (v 3.6 or more). &lt;br /&gt;
:The internationalization in PHP is provided by modules which are built with the internationalization extension. PHP applies i18n in one of the following ways:&lt;br /&gt;
#'''Using Object-Oriented API :''' &amp;lt;br&amp;gt;This makes of the object-oriented API provided by the modules. This method represents the modules in the form of classes.&lt;br /&gt;
#'''Using Procedural API :''' &amp;lt;br&amp;gt;This makes use of the procedural API provided by the modules. This method represents the modules in the form of a group of functions.&lt;br /&gt;
:Note: Each module provided both of the above API’s.&lt;br /&gt;
:Each of these modules provide different functionality of internationalization. For example PHP has modules like:&lt;br /&gt;
&lt;br /&gt;
#'''Locale''' —  This mainly deals with breaking and assembling of strings from components and displaying them in a specified locale.&lt;br /&gt;
#'''Collator''' —  This maily deals with comparison and sorting of strings according to the rules of the specified locale.&lt;br /&gt;
#'''Number formatter''' — This mainly deals with formatting number in a specific way according to a locale and also parses textual representations of numbers.&lt;br /&gt;
#'''Date formatter''' —  This formats dates in accordance to the specified locale.&lt;br /&gt;
:and many more… &lt;br /&gt;
&lt;br /&gt;
:PHP also has specific functions who return internationalization errors. These functions serve all the available modules.&lt;br /&gt;
&lt;br /&gt;
== Comparison with Ruby : ==&lt;br /&gt;
&lt;br /&gt;
#Internationalization in PHP is a bit easy as compared to ruby. Because the way to implement internationalization is very similar to creating an object of a class and then using one of the functions of the classes. And hence the programmer is familiar with the syntax.&lt;br /&gt;
#Whenever we need to add more features to internationalization, in PHP we just have to add a module to the internationalization extension.&lt;br /&gt;
#In PHP, we have functions that are written specifically to return internationalization errors. This helps in making debugging easy in case i18n fails. In ruby we don’t have such dedicated functions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
http://guides.rubyonrails.org/3_0_release_notes.html &amp;lt;br&amp;gt;&lt;br /&gt;
http://rubylearning.com/blog/2012/07/24/minimal-i18n-with-rails-3-2/ &amp;lt;br&amp;gt;&lt;br /&gt;
http://blog.lingohub.com/developers/2013/08/internationalization-for-ruby-i18n-gem/ &amp;lt;br&amp;gt;&lt;br /&gt;
http://vimeo.com/12665914 &amp;lt;br&amp;gt;&lt;br /&gt;
http://www.artweb-design.de/2009/7/19/experimental-extensions-in-i18n-pluralization-fallbacks-gettext-cache-and-chain &amp;lt;br&amp;gt;&lt;br /&gt;
http://asciicasts.com/episodes/256-i18n-backends &amp;lt;br&amp;gt;&lt;br /&gt;
http://blog.lingohub.com/developers/2013/08/i18n-gem-advanced-features-ruby-rails-internationalization/ &amp;lt;br&amp;gt;&lt;br /&gt;
http://en.wikipedia.org/wiki/Internationalization_and_localization &amp;lt;br&amp;gt;&lt;br /&gt;
http://www.ruby-doc.org/gems/docs/s/synergy_russian-0.2.8/I18n/Backend/Simple.html &amp;lt;br&amp;gt;&lt;br /&gt;
https://github.com/svenfuchs/i18n &amp;lt;br&amp;gt;&lt;br /&gt;
http://guides.rubyonrails.org/v2.3.11/i18n.html &amp;lt;br&amp;gt;&lt;br /&gt;
http://www.slideshare.net/Belighted/internationalization-in-rails-22-3120853 &amp;lt;br&amp;gt;&lt;br /&gt;
http://www.slideshare.net/graysky/rails-internationalization &amp;lt;br&amp;gt;&lt;br /&gt;
http://www.slideshare.net/ &amp;lt;br&amp;gt;&lt;br /&gt;
http://devzone.zend.com/1500/internationalization-in-php-53/  &amp;lt;br&amp;gt;&lt;br /&gt;
http://www.php.net/manual/en/intro.intl.php &amp;lt;br&amp;gt;	&lt;br /&gt;
http://www.php.net/manual/en/intl.requirements.php &amp;lt;br&amp;gt;&lt;br /&gt;
http://www.php.net/manual/en/intl.installation.php &amp;lt;br&amp;gt;&lt;br /&gt;
http://www.php.net/manual/en/intl.configuration.php &amp;lt;br&amp;gt;&lt;br /&gt;
http://www.php.net/manual/en/intl.examples.basic.php &amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Srparadk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w18_bs&amp;diff=76945</id>
		<title>CSC/ECE 517 Fall 2013/ch1 1w18 bs</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w18_bs&amp;diff=76945"/>
		<updated>2013-09-17T18:58:02Z</updated>

		<summary type="html">&lt;p&gt;Srparadk: /* Internationalization in PHP */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Internationalization in Rails&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
:In general when we start a conversation, the first default language of communication we use is English, but if the other person is not familiar with English we try and translate our dialogue in a language that the person is familiar with. Similarly whenever we write a program or a document we write it in English by default. But what if someone who is not familiar with English wants to read your program or code? The simple solution is that we translate program or code into a language that the person is familiar with. And for this, we use a term called internationalization.&lt;br /&gt;
&lt;br /&gt;
:Internationalization is a way by which we can view an application in various languages without actually making changes to the code of the application. This saves us a lot of time and effort, as we don’t have to write or edit the same code or document in all the copies.&lt;br /&gt;
&lt;br /&gt;
:Internationalization has an acronym, rather more of a numeronym ,which is i18n where the number 18 represents the number of letters between the first and last letters in the word internationalization.&lt;br /&gt;
&lt;br /&gt;
== Aspects to consider in Internationalization ==&lt;br /&gt;
&lt;br /&gt;
:Now when we are to change our application according to a particular language or a region , we need to keep in mind numerous points that are important, implicit, particular or sensitive to that language or region. Like for example when we take a language into consideration for which our application needs to be translated, we need to consider the spoken and written aspects of that language. Also, there might be a case when we have the same language but it differs from one region to other. For this we need to keep in mind the typical change in the use of words, grammar and symbol for each region that uses the same language. Our application must also provide support for the varied writing conventions that differ from a language to another language or from one region to another.&lt;br /&gt;
&lt;br /&gt;
:Below are the examples of the points we need to keep in mind while we provide internationalization to our application :&lt;br /&gt;
&lt;br /&gt;
* Language :&lt;br /&gt;
&lt;br /&gt;
:Here the i18n support to an application needs to provide the character encoding keeping in mind the following points:&lt;br /&gt;
&lt;br /&gt;
#The written language differs. For example most of the languages like English, French, German follow a script that can have inputs from a standard keyboard. But there are other languages like Hindi, Marathi, Sanskrit that follow a script called Devnagri and this cannot be directly typed in from a standard keyboard. So if we have to provide support for these languages we need to support the translation of the characters used in these scripts.&lt;br /&gt;
#The way we write also differs and needs to included in our i18n support. For example most of the languages follow a left-right direction while writing but some languages like Urdu tend to follow a right-left direction.&lt;br /&gt;
#The numbering symbols also vary from language to language. So when we display or accept any text with numbers, we must have i18n to support this mapping.&lt;br /&gt;
#The languages also differ in the use of grammar and structure of the sentences.For example the grammar rules and structure formation in English is way different than the one followed by another language like Sanskrit.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Culture and Writing Conventions:&lt;br /&gt;
&lt;br /&gt;
:Even if the language with the same characters and grammar is used, the use of the language , the symbols , the way of writing and many other things change with change in the region.&lt;br /&gt;
:Following are some of the examples:&lt;br /&gt;
&lt;br /&gt;
#There are some cultures that have some regulations about having a middle name as father’s name but other cultures don’t necessary include the middle name.&lt;br /&gt;
#There might be cases when there are different names or terminologies used in different cultures for the same purpose. For example, to identify a citizen uniquely US has the system of SSN while India is in the process of implementing this by using the term as Aadhar number.&lt;br /&gt;
#Another example of difference in the writing convention can be taken as that of a postal code. Some countries have 6 digit postal codes while others have 5.&lt;br /&gt;
#There is a difference in the use of many other things like the currency(like INR,dollars,Euro) used, the symbols(€,$,₹) used , the units in which the weights , temperature are measured. Another example could be the use of lakhs , crores for mentioning any financial figures in some countries while others use millions, billions.&lt;br /&gt;
#There could also be a difference in the formats used for a same thing. For example the format of writing dates and times vary from one region to another.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* We also have to be careful that we cover all the sensitive topics and issues particular to a language or region.&lt;br /&gt;
&lt;br /&gt;
:Similarly there are many other factors that we need to take care of when we support internationalization for a particular language in a particular region.&lt;br /&gt;
&lt;br /&gt;
= Internationalization in Rails =&lt;br /&gt;
&lt;br /&gt;
:Internationalization support was extended from Rails version 2.2. So in order to internationalize a rails application, it has to be migrated :to Rails 2.2 or above. Every static string in the Rails framework — e.g. Active Record validation messages, time and date formats — have :been internationalized.&lt;br /&gt;
&lt;br /&gt;
:Following needs to be done in order to internationalize a rails application:&lt;br /&gt;
:#Ensure support for internationalization by migrating to appropriate version of rails if needed.&lt;br /&gt;
:#Tell rails where to find the appropriate translations files&lt;br /&gt;
:#Tell rails how to switch locales&lt;br /&gt;
&lt;br /&gt;
::YAML (.yml) or plain Ruby (.rb) files are used for storing translations.&lt;br /&gt;
&lt;br /&gt;
== History ==&lt;br /&gt;
&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100pt&amp;quot;| Ruby 2.2    || Internationalization support was extended from this version of Rails.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 2.3    || Additional feature for Localized Views was added in this version. The view files were rendered with an extension of the locale name.I18n#available_locales and I18n::SimpleBackend#available_locales is available to retrieve an array of available locales.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 3.0    || Some additional features were added to the I18n gem for speed improvements like default translations for attributes,automatic pull for translations on form submit, etc.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 3.1    || I18n namespace lookup support removed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Ways to configure Internationalization in Rails ==&lt;br /&gt;
&lt;br /&gt;
:We can set up a rails application to support internationalization in a number of ways. Below are the various ways to configure our rails application for internationalization.&lt;br /&gt;
&lt;br /&gt;
#'''Configure the I18n module:'''&amp;lt;br&amp;gt;Rails adds all .rb and .yml files from the config/locales directory to your translations load path, automatically. This is the default setting provided by the [https://github.com/svenfuchs/i18n I18n gem]. In order to override this setting we have to make changes in the application.rb files that have instructions on how to add locales from another directory and how to set a different default locale.&lt;br /&gt;
#'''Custom I18n Configuration Setup:'''&amp;lt;br&amp;gt;Optionally, the above code can be placed anywhere in the application preferably in initializers.&lt;br /&gt;
#'''Setting and passing locale:'''&amp;lt;br&amp;gt;The above two steps help setup a default locale throughout the application. But in case we have to provide our application in different languages, we can setup the application default locale in the application.rb and then set the locale using the application-controller.rb before_action. We can then pass the locale we want as a query param for example http://study.com/books?locale=es&lt;br /&gt;
#'''Setting the locale from the domain name:'''&amp;lt;br&amp;gt;Similar to option 3 but instead of passing the locale as a query param, the locale is a part of the domain name itself. Example http://study.es&lt;br /&gt;
::You can implement it like this in your ApplicationController before_action&lt;br /&gt;
#'''Setting the locale from the URL params:'''&amp;lt;br&amp;gt;&lt;br /&gt;
##This can be a tedious task as we have to pass the locale on each request. &lt;br /&gt;
##Rails provides us an alternative for &amp;quot;centralizing dynamic decisions about the URLs&amp;quot; in its ApplicationController#default_url_options and helper methods are dependent on it (by implementing/overriding this method). This will now automatically include the locale param in the query string&lt;br /&gt;
##We can also set the locale in the URL route. For example -http://study.com/es/books .This is achievable by using over-riding default_url_options. You just have to set up your routes with scoping option in routes.rb. &lt;br /&gt;
#'''Setting the locale from client supplied information:'''&amp;lt;br&amp;gt;This can be done in 3 ways&lt;br /&gt;
##Using the default locale of the client browser&lt;br /&gt;
##Using client location to select the locale&lt;br /&gt;
##Saving the users choice of locale as a part of user profile&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Internationalizing Rails application ==&lt;br /&gt;
&lt;br /&gt;
:After your application is prepared for internationalization, we need to use the feature in our application. &lt;br /&gt;
:This can be done in the following ways:&lt;br /&gt;
&lt;br /&gt;
1. '''Adding Translations:'''&lt;br /&gt;
:In order to internationalize rails code, replace the strings with calls to  the ‘t’ helper.&amp;lt;br&amp;gt;For example: &lt;br /&gt;
 class HelloWorld &lt;br /&gt;
  def sayHello&lt;br /&gt;
    puts t(:hello_world)&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;%=t :hello_world %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:The helper method t also catches missing translations and displays appropriate error message.&lt;br /&gt;
 &amp;lt;nowiki /&amp;gt;# config/locales/en.yml&lt;br /&gt;
 en: hello_world: Hello world!&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki /&amp;gt;# config/locales/es.yml&lt;br /&gt;
 es: hello_world: hola mundo&lt;br /&gt;
&lt;br /&gt;
2. '''Passing variables to translation:'''&lt;br /&gt;
:You can use variables in the translation messages and pass their values from the view.&lt;br /&gt;
 en:&lt;br /&gt;
 portal: &amp;quot;Mypack&amp;quot;&lt;br /&gt;
   university:&lt;br /&gt;
    ncsu:&lt;br /&gt;
    description: ! 'NCSU student information is accessed on %{portal_name}’ &lt;br /&gt;
&lt;br /&gt;
 t('.description', portal_name: t(‘portal’))&lt;br /&gt;
&lt;br /&gt;
3. '''Adding date/ time formats:'''&lt;br /&gt;
:OK! Now let's add a timestamp to the view, so we can demo the date/time localization feature as well. To localize the time format you pass the Time object to I18n.l or (preferably) use ‘l’ helper. You can pick a format by passing the :format option — by default the :default format is used.&lt;br /&gt;
:In the view file:&lt;br /&gt;
 &amp;lt;%= l Time.now, format: :short %&amp;gt;&lt;br /&gt;
:In the yml file:&lt;br /&gt;
  es:&lt;br /&gt;
   time:&lt;br /&gt;
     formats:&lt;br /&gt;
       short: &amp;quot; Son las %H&amp;quot;&lt;br /&gt;
&lt;br /&gt;
4. '''Inflection rules for locales other than english:'''&lt;br /&gt;
:Rails 4.0 provides a feature to define inflection rules (singularization and pluralization)  in config/initializers/inflections.rb. &lt;br /&gt;
&lt;br /&gt;
5. '''Localized views:'''&lt;br /&gt;
:For static websites available in different languages or for large static content, localized views is a useful feature. This feature enables having separate view file for different locales. For example for default locale we can have show.html.erb file while for Spanish we can have show.es.html.erb. Thus we don’t need to maintain long .yml files for each supported locale for long static pages.&lt;br /&gt;
&lt;br /&gt;
== Internationalization Features ==&lt;br /&gt;
&lt;br /&gt;
1. '''Using Different Backends:'''&lt;br /&gt;
:The i18n provides a [http://www.ruby-doc.org/gems/docs/s/synergy_russian-0.2.8/I18n/Backend/Simple.html simple backend] by default. We can change the backend to an active records backend or chain multiple backends as per the requirements of our application. I18n gem also provides cache, fallback and pluralization feature for the backends.&lt;br /&gt;
&lt;br /&gt;
2. '''Pluralization:'''&lt;br /&gt;
:Different languages have different rules for pluralization. Thus, the I18n API provides a flexible pluralization feature.&lt;br /&gt;
&lt;br /&gt;
3. '''Fallbacks:'''&lt;br /&gt;
:In case translation for a certain  locale is missing we can define fallback chain for the locales.&lt;br /&gt;
:For example we can define a fallback chain of the form &lt;br /&gt;
 :'en-CA' =&amp;gt; :'en-US', :'en-US' =&amp;gt; :en, :de =&amp;gt; :en &lt;br /&gt;
&lt;br /&gt;
:if the translation for en-CA is missing rails looks for en-US , if en-US is missing it then looks for en and so on.&lt;br /&gt;
&lt;br /&gt;
4. '''Cascading lookups:'''&lt;br /&gt;
:If a given key is not found, it is broken and a lookup is performed for the remaining portion of the key before finally falling back to the defaults.&lt;br /&gt;
&lt;br /&gt;
5. '''Translation symlinks:'''&lt;br /&gt;
:A key can be a value for another key.&lt;br /&gt;
:Example:&lt;br /&gt;
 person: ‘ash’&lt;br /&gt;
 student: :person&lt;br /&gt;
 employee: :person&lt;br /&gt;
&lt;br /&gt;
:Ash can be an employee or a student. Each key represents the same value.&lt;br /&gt;
&lt;br /&gt;
6. '''Translation procs:'''&lt;br /&gt;
:I18n gem allows writing translation logic in the translation lookup process.&lt;br /&gt;
:For example:&lt;br /&gt;
 :en&lt;br /&gt;
  	:addressing =&amp;gt; lambda { |values|&lt;br /&gt;
 		person=values[:person]&lt;br /&gt;
 		address=person.male? ?  “Sir” : “Madam”&lt;br /&gt;
 	“Hello, #{person.address}”&lt;br /&gt;
 &lt;br /&gt;
 t(:addressing , :person =&amp;gt; mary)&lt;br /&gt;
&lt;br /&gt;
= Advantages of Internationalization = &lt;br /&gt;
&lt;br /&gt;
#Internationalization opens up a whole new market for applications. For example, consider a website which has support for internationalization and because of that it can be displayed in a number of languages. This opens a lot of new markets, business opportunities and a large number of potential customers.&lt;br /&gt;
#With the help of the internationalization gem, the application code has been simplified.&lt;br /&gt;
#The maintenance of the code is also made easy.  Also, the steps to add support to a new language are quite simple. &lt;br /&gt;
#Internationalization in rails(i18n gem) provides a variety of ways to incorporate internationalization in our application. This makes it easier for the developer to adopt a method that suits his application. For example, for a static application we can we one configuration technique and say for a dynamic application we can follow another configuration method for internationalization.&lt;br /&gt;
&lt;br /&gt;
= Internationalization in PHP, Java =&lt;br /&gt;
== Internationalization in PHP ==&lt;br /&gt;
&lt;br /&gt;
:In PHP, we need to install/enable extensions to support internationalization(not required with PHP 5.3.0 version). For building the internationalization tool we must have  ICU library (v 3.6 or more). &lt;br /&gt;
:The internationalization in PHP is provided by modules which are built with the internationalization extension. PHP applies i18n in one of the following ways:&lt;br /&gt;
#'''Using Object-Oriented API :''' &amp;lt;br&amp;gt;This makes of the object-oriented API provided by the modules. This method represents the modules in the form of classes.&lt;br /&gt;
#'''Using Procedural API :''' &amp;lt;br&amp;gt;This makes use of the procedural API provided by the modules. This method represents the modules in the form of a group of functions.&lt;br /&gt;
:Note: Each module provided both of the above API’s.&lt;br /&gt;
:Each of these modules provide different functionality of internationalization. For example PHP has modules like:&lt;br /&gt;
&lt;br /&gt;
#'''Locale''' —  This mainly deals with breaking and assembling of strings from components and displaying them in a specified locale.&lt;br /&gt;
#'''Collator''' —  This maily deals with comparison and sorting of strings according to the rules of the specified locale.&lt;br /&gt;
#'''Number formatter''' — This mainly deals with formatting number in a specific way according to a locale and also parses textual representations of numbers.&lt;br /&gt;
#'''Date formatter''' —  This formats dates in accordance to the specified locale.&lt;br /&gt;
:and many more… &lt;br /&gt;
&lt;br /&gt;
:PHP also has specific functions who return internationalization errors. These functions serve all the available modules.&lt;br /&gt;
&lt;br /&gt;
== Comparison with Ruby : ==&lt;br /&gt;
&lt;br /&gt;
#Internationalization in PHP is a bit easy as compared to ruby. Because the way to implement internationalization is very similar to creating an object of a class and then using one of the functions of the classes. And hence the programmer is familiar with the syntax.&lt;br /&gt;
#Whenever we need to add more features to internationalization, in PHP we just have to add a module to the internationalization extension.&lt;br /&gt;
#In PHP, we have functions that are written specifically to return internationalization errors. This helps in making debugging easy in case i18n fails. In ruby we don’t have such dedicated functions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
http://guides.rubyonrails.org/3_0_release_notes.html &amp;lt;br&amp;gt;&lt;br /&gt;
http://rubylearning.com/blog/2012/07/24/minimal-i18n-with-rails-3-2/ &amp;lt;br&amp;gt;&lt;br /&gt;
http://blog.lingohub.com/developers/2013/08/internationalization-for-ruby-i18n-gem/ &amp;lt;br&amp;gt;&lt;br /&gt;
http://vimeo.com/12665914 &amp;lt;br&amp;gt;&lt;br /&gt;
http://www.artweb-design.de/2009/7/19/experimental-extensions-in-i18n-pluralization-fallbacks-gettext-cache-and-chain &amp;lt;br&amp;gt;&lt;br /&gt;
http://asciicasts.com/episodes/256-i18n-backends &amp;lt;br&amp;gt;&lt;br /&gt;
http://blog.lingohub.com/developers/2013/08/i18n-gem-advanced-features-ruby-rails-internationalization/ &amp;lt;br&amp;gt;&lt;br /&gt;
http://en.wikipedia.org/wiki/Internationalization_and_localization &amp;lt;br&amp;gt;&lt;br /&gt;
http://www.ruby-doc.org/gems/docs/s/synergy_russian-0.2.8/I18n/Backend/Simple.html &amp;lt;br&amp;gt;&lt;br /&gt;
https://github.com/svenfuchs/i18n &amp;lt;br&amp;gt;&lt;br /&gt;
http://guides.rubyonrails.org/v2.3.11/i18n.html &amp;lt;br&amp;gt;&lt;br /&gt;
http://www.slideshare.net/Belighted/internationalization-in-rails-22-3120853 &amp;lt;br&amp;gt;&lt;br /&gt;
http://www.slideshare.net/graysky/rails-internationalization &amp;lt;br&amp;gt;&lt;br /&gt;
http://www.slideshare.net/ &amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Srparadk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w18_bs&amp;diff=76944</id>
		<title>CSC/ECE 517 Fall 2013/ch1 1w18 bs</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w18_bs&amp;diff=76944"/>
		<updated>2013-09-17T18:57:31Z</updated>

		<summary type="html">&lt;p&gt;Srparadk: /* Internationalization in PHP */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Internationalization in Rails&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
:In general when we start a conversation, the first default language of communication we use is English, but if the other person is not familiar with English we try and translate our dialogue in a language that the person is familiar with. Similarly whenever we write a program or a document we write it in English by default. But what if someone who is not familiar with English wants to read your program or code? The simple solution is that we translate program or code into a language that the person is familiar with. And for this, we use a term called internationalization.&lt;br /&gt;
&lt;br /&gt;
:Internationalization is a way by which we can view an application in various languages without actually making changes to the code of the application. This saves us a lot of time and effort, as we don’t have to write or edit the same code or document in all the copies.&lt;br /&gt;
&lt;br /&gt;
:Internationalization has an acronym, rather more of a numeronym ,which is i18n where the number 18 represents the number of letters between the first and last letters in the word internationalization.&lt;br /&gt;
&lt;br /&gt;
== Aspects to consider in Internationalization ==&lt;br /&gt;
&lt;br /&gt;
:Now when we are to change our application according to a particular language or a region , we need to keep in mind numerous points that are important, implicit, particular or sensitive to that language or region. Like for example when we take a language into consideration for which our application needs to be translated, we need to consider the spoken and written aspects of that language. Also, there might be a case when we have the same language but it differs from one region to other. For this we need to keep in mind the typical change in the use of words, grammar and symbol for each region that uses the same language. Our application must also provide support for the varied writing conventions that differ from a language to another language or from one region to another.&lt;br /&gt;
&lt;br /&gt;
:Below are the examples of the points we need to keep in mind while we provide internationalization to our application :&lt;br /&gt;
&lt;br /&gt;
* Language :&lt;br /&gt;
&lt;br /&gt;
:Here the i18n support to an application needs to provide the character encoding keeping in mind the following points:&lt;br /&gt;
&lt;br /&gt;
#The written language differs. For example most of the languages like English, French, German follow a script that can have inputs from a standard keyboard. But there are other languages like Hindi, Marathi, Sanskrit that follow a script called Devnagri and this cannot be directly typed in from a standard keyboard. So if we have to provide support for these languages we need to support the translation of the characters used in these scripts.&lt;br /&gt;
#The way we write also differs and needs to included in our i18n support. For example most of the languages follow a left-right direction while writing but some languages like Urdu tend to follow a right-left direction.&lt;br /&gt;
#The numbering symbols also vary from language to language. So when we display or accept any text with numbers, we must have i18n to support this mapping.&lt;br /&gt;
#The languages also differ in the use of grammar and structure of the sentences.For example the grammar rules and structure formation in English is way different than the one followed by another language like Sanskrit.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Culture and Writing Conventions:&lt;br /&gt;
&lt;br /&gt;
:Even if the language with the same characters and grammar is used, the use of the language , the symbols , the way of writing and many other things change with change in the region.&lt;br /&gt;
:Following are some of the examples:&lt;br /&gt;
&lt;br /&gt;
#There are some cultures that have some regulations about having a middle name as father’s name but other cultures don’t necessary include the middle name.&lt;br /&gt;
#There might be cases when there are different names or terminologies used in different cultures for the same purpose. For example, to identify a citizen uniquely US has the system of SSN while India is in the process of implementing this by using the term as Aadhar number.&lt;br /&gt;
#Another example of difference in the writing convention can be taken as that of a postal code. Some countries have 6 digit postal codes while others have 5.&lt;br /&gt;
#There is a difference in the use of many other things like the currency(like INR,dollars,Euro) used, the symbols(€,$,₹) used , the units in which the weights , temperature are measured. Another example could be the use of lakhs , crores for mentioning any financial figures in some countries while others use millions, billions.&lt;br /&gt;
#There could also be a difference in the formats used for a same thing. For example the format of writing dates and times vary from one region to another.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* We also have to be careful that we cover all the sensitive topics and issues particular to a language or region.&lt;br /&gt;
&lt;br /&gt;
:Similarly there are many other factors that we need to take care of when we support internationalization for a particular language in a particular region.&lt;br /&gt;
&lt;br /&gt;
= Internationalization in Rails =&lt;br /&gt;
&lt;br /&gt;
:Internationalization support was extended from Rails version 2.2. So in order to internationalize a rails application, it has to be migrated :to Rails 2.2 or above. Every static string in the Rails framework — e.g. Active Record validation messages, time and date formats — have :been internationalized.&lt;br /&gt;
&lt;br /&gt;
:Following needs to be done in order to internationalize a rails application:&lt;br /&gt;
:#Ensure support for internationalization by migrating to appropriate version of rails if needed.&lt;br /&gt;
:#Tell rails where to find the appropriate translations files&lt;br /&gt;
:#Tell rails how to switch locales&lt;br /&gt;
&lt;br /&gt;
::YAML (.yml) or plain Ruby (.rb) files are used for storing translations.&lt;br /&gt;
&lt;br /&gt;
== History ==&lt;br /&gt;
&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100pt&amp;quot;| Ruby 2.2    || Internationalization support was extended from this version of Rails.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 2.3    || Additional feature for Localized Views was added in this version. The view files were rendered with an extension of the locale name.I18n#available_locales and I18n::SimpleBackend#available_locales is available to retrieve an array of available locales.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 3.0    || Some additional features were added to the I18n gem for speed improvements like default translations for attributes,automatic pull for translations on form submit, etc.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 3.1    || I18n namespace lookup support removed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Ways to configure Internationalization in Rails ==&lt;br /&gt;
&lt;br /&gt;
:We can set up a rails application to support internationalization in a number of ways. Below are the various ways to configure our rails application for internationalization.&lt;br /&gt;
&lt;br /&gt;
#'''Configure the I18n module:'''&amp;lt;br&amp;gt;Rails adds all .rb and .yml files from the config/locales directory to your translations load path, automatically. This is the default setting provided by the [https://github.com/svenfuchs/i18n I18n gem]. In order to override this setting we have to make changes in the application.rb files that have instructions on how to add locales from another directory and how to set a different default locale.&lt;br /&gt;
#'''Custom I18n Configuration Setup:'''&amp;lt;br&amp;gt;Optionally, the above code can be placed anywhere in the application preferably in initializers.&lt;br /&gt;
#'''Setting and passing locale:'''&amp;lt;br&amp;gt;The above two steps help setup a default locale throughout the application. But in case we have to provide our application in different languages, we can setup the application default locale in the application.rb and then set the locale using the application-controller.rb before_action. We can then pass the locale we want as a query param for example http://study.com/books?locale=es&lt;br /&gt;
#'''Setting the locale from the domain name:'''&amp;lt;br&amp;gt;Similar to option 3 but instead of passing the locale as a query param, the locale is a part of the domain name itself. Example http://study.es&lt;br /&gt;
::You can implement it like this in your ApplicationController before_action&lt;br /&gt;
#'''Setting the locale from the URL params:'''&amp;lt;br&amp;gt;&lt;br /&gt;
##This can be a tedious task as we have to pass the locale on each request. &lt;br /&gt;
##Rails provides us an alternative for &amp;quot;centralizing dynamic decisions about the URLs&amp;quot; in its ApplicationController#default_url_options and helper methods are dependent on it (by implementing/overriding this method). This will now automatically include the locale param in the query string&lt;br /&gt;
##We can also set the locale in the URL route. For example -http://study.com/es/books .This is achievable by using over-riding default_url_options. You just have to set up your routes with scoping option in routes.rb. &lt;br /&gt;
#'''Setting the locale from client supplied information:'''&amp;lt;br&amp;gt;This can be done in 3 ways&lt;br /&gt;
##Using the default locale of the client browser&lt;br /&gt;
##Using client location to select the locale&lt;br /&gt;
##Saving the users choice of locale as a part of user profile&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Internationalizing Rails application ==&lt;br /&gt;
&lt;br /&gt;
:After your application is prepared for internationalization, we need to use the feature in our application. &lt;br /&gt;
:This can be done in the following ways:&lt;br /&gt;
&lt;br /&gt;
1. '''Adding Translations:'''&lt;br /&gt;
:In order to internationalize rails code, replace the strings with calls to  the ‘t’ helper.&amp;lt;br&amp;gt;For example: &lt;br /&gt;
 class HelloWorld &lt;br /&gt;
  def sayHello&lt;br /&gt;
    puts t(:hello_world)&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;%=t :hello_world %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:The helper method t also catches missing translations and displays appropriate error message.&lt;br /&gt;
 &amp;lt;nowiki /&amp;gt;# config/locales/en.yml&lt;br /&gt;
 en: hello_world: Hello world!&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki /&amp;gt;# config/locales/es.yml&lt;br /&gt;
 es: hello_world: hola mundo&lt;br /&gt;
&lt;br /&gt;
2. '''Passing variables to translation:'''&lt;br /&gt;
:You can use variables in the translation messages and pass their values from the view.&lt;br /&gt;
 en:&lt;br /&gt;
 portal: &amp;quot;Mypack&amp;quot;&lt;br /&gt;
   university:&lt;br /&gt;
    ncsu:&lt;br /&gt;
    description: ! 'NCSU student information is accessed on %{portal_name}’ &lt;br /&gt;
&lt;br /&gt;
 t('.description', portal_name: t(‘portal’))&lt;br /&gt;
&lt;br /&gt;
3. '''Adding date/ time formats:'''&lt;br /&gt;
:OK! Now let's add a timestamp to the view, so we can demo the date/time localization feature as well. To localize the time format you pass the Time object to I18n.l or (preferably) use ‘l’ helper. You can pick a format by passing the :format option — by default the :default format is used.&lt;br /&gt;
:In the view file:&lt;br /&gt;
 &amp;lt;%= l Time.now, format: :short %&amp;gt;&lt;br /&gt;
:In the yml file:&lt;br /&gt;
  es:&lt;br /&gt;
   time:&lt;br /&gt;
     formats:&lt;br /&gt;
       short: &amp;quot; Son las %H&amp;quot;&lt;br /&gt;
&lt;br /&gt;
4. '''Inflection rules for locales other than english:'''&lt;br /&gt;
:Rails 4.0 provides a feature to define inflection rules (singularization and pluralization)  in config/initializers/inflections.rb. &lt;br /&gt;
&lt;br /&gt;
5. '''Localized views:'''&lt;br /&gt;
:For static websites available in different languages or for large static content, localized views is a useful feature. This feature enables having separate view file for different locales. For example for default locale we can have show.html.erb file while for Spanish we can have show.es.html.erb. Thus we don’t need to maintain long .yml files for each supported locale for long static pages.&lt;br /&gt;
&lt;br /&gt;
== Internationalization Features ==&lt;br /&gt;
&lt;br /&gt;
1. '''Using Different Backends:'''&lt;br /&gt;
:The i18n provides a [http://www.ruby-doc.org/gems/docs/s/synergy_russian-0.2.8/I18n/Backend/Simple.html simple backend] by default. We can change the backend to an active records backend or chain multiple backends as per the requirements of our application. I18n gem also provides cache, fallback and pluralization feature for the backends.&lt;br /&gt;
&lt;br /&gt;
2. '''Pluralization:'''&lt;br /&gt;
:Different languages have different rules for pluralization. Thus, the I18n API provides a flexible pluralization feature.&lt;br /&gt;
&lt;br /&gt;
3. '''Fallbacks:'''&lt;br /&gt;
:In case translation for a certain  locale is missing we can define fallback chain for the locales.&lt;br /&gt;
:For example we can define a fallback chain of the form &lt;br /&gt;
 :'en-CA' =&amp;gt; :'en-US', :'en-US' =&amp;gt; :en, :de =&amp;gt; :en &lt;br /&gt;
&lt;br /&gt;
:if the translation for en-CA is missing rails looks for en-US , if en-US is missing it then looks for en and so on.&lt;br /&gt;
&lt;br /&gt;
4. '''Cascading lookups:'''&lt;br /&gt;
:If a given key is not found, it is broken and a lookup is performed for the remaining portion of the key before finally falling back to the defaults.&lt;br /&gt;
&lt;br /&gt;
5. '''Translation symlinks:'''&lt;br /&gt;
:A key can be a value for another key.&lt;br /&gt;
:Example:&lt;br /&gt;
 person: ‘ash’&lt;br /&gt;
 student: :person&lt;br /&gt;
 employee: :person&lt;br /&gt;
&lt;br /&gt;
:Ash can be an employee or a student. Each key represents the same value.&lt;br /&gt;
&lt;br /&gt;
6. '''Translation procs:'''&lt;br /&gt;
:I18n gem allows writing translation logic in the translation lookup process.&lt;br /&gt;
:For example:&lt;br /&gt;
 :en&lt;br /&gt;
  	:addressing =&amp;gt; lambda { |values|&lt;br /&gt;
 		person=values[:person]&lt;br /&gt;
 		address=person.male? ?  “Sir” : “Madam”&lt;br /&gt;
 	“Hello, #{person.address}”&lt;br /&gt;
 &lt;br /&gt;
 t(:addressing , :person =&amp;gt; mary)&lt;br /&gt;
&lt;br /&gt;
= Advantages of Internationalization = &lt;br /&gt;
&lt;br /&gt;
#Internationalization opens up a whole new market for applications. For example, consider a website which has support for internationalization and because of that it can be displayed in a number of languages. This opens a lot of new markets, business opportunities and a large number of potential customers.&lt;br /&gt;
#With the help of the internationalization gem, the application code has been simplified.&lt;br /&gt;
#The maintenance of the code is also made easy.  Also, the steps to add support to a new language are quite simple. &lt;br /&gt;
#Internationalization in rails(i18n gem) provides a variety of ways to incorporate internationalization in our application. This makes it easier for the developer to adopt a method that suits his application. For example, for a static application we can we one configuration technique and say for a dynamic application we can follow another configuration method for internationalization.&lt;br /&gt;
&lt;br /&gt;
= Internationalization in PHP, Java =&lt;br /&gt;
== Internationalization in PHP ==&lt;br /&gt;
&lt;br /&gt;
:In PHP, we need to install/enable extensions to support internationalization(not required with PHP 5.3.0 version). For building the internationalization tool we must have  ICU library (v 3.6 or more). &lt;br /&gt;
:The internationalization in PHP is provided by modules which are built with the internationalization extension. PHP applies i18n in one of the following ways:&lt;br /&gt;
#'''Using Object-Oriented API :''' &amp;lt;br&amp;gt;This makes of the object-oriented API provided by the modules. This method represents the modules in the form of classes.&lt;br /&gt;
#'''Using Procedural API :'''&lt;br /&gt;
:This makes use of the procedural API provided by the modules. This method represents the modules in the form of a group of functions.&lt;br /&gt;
:Note: Each module provided both of the above API’s.&lt;br /&gt;
:Each of these modules provide different functionality of internationalization. For example PHP has modules like:&lt;br /&gt;
&lt;br /&gt;
#'''Locale''' —  This mainly deals with breaking and assembling of strings from components and displaying them in a specified locale.&lt;br /&gt;
#'''Collator''' —  This maily deals with comparison and sorting of strings according to the rules of the specified locale.&lt;br /&gt;
#'''Number formatter''' — This mainly deals with formatting number in a specific way according to a locale and also parses textual representations of numbers.&lt;br /&gt;
#'''Date formatter''' —  This formats dates in accordance to the specified locale.&lt;br /&gt;
:and many more… &lt;br /&gt;
&lt;br /&gt;
:PHP also has specific functions who return internationalization errors. These functions serve all the available modules.&lt;br /&gt;
&lt;br /&gt;
== Comparison with Ruby : ==&lt;br /&gt;
&lt;br /&gt;
#Internationalization in PHP is a bit easy as compared to ruby. Because the way to implement internationalization is very similar to creating an object of a class and then using one of the functions of the classes. And hence the programmer is familiar with the syntax.&lt;br /&gt;
#Whenever we need to add more features to internationalization, in PHP we just have to add a module to the internationalization extension.&lt;br /&gt;
#In PHP, we have functions that are written specifically to return internationalization errors. This helps in making debugging easy in case i18n fails. In ruby we don’t have such dedicated functions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
http://guides.rubyonrails.org/3_0_release_notes.html &amp;lt;br&amp;gt;&lt;br /&gt;
http://rubylearning.com/blog/2012/07/24/minimal-i18n-with-rails-3-2/ &amp;lt;br&amp;gt;&lt;br /&gt;
http://blog.lingohub.com/developers/2013/08/internationalization-for-ruby-i18n-gem/ &amp;lt;br&amp;gt;&lt;br /&gt;
http://vimeo.com/12665914 &amp;lt;br&amp;gt;&lt;br /&gt;
http://www.artweb-design.de/2009/7/19/experimental-extensions-in-i18n-pluralization-fallbacks-gettext-cache-and-chain &amp;lt;br&amp;gt;&lt;br /&gt;
http://asciicasts.com/episodes/256-i18n-backends &amp;lt;br&amp;gt;&lt;br /&gt;
http://blog.lingohub.com/developers/2013/08/i18n-gem-advanced-features-ruby-rails-internationalization/ &amp;lt;br&amp;gt;&lt;br /&gt;
http://en.wikipedia.org/wiki/Internationalization_and_localization &amp;lt;br&amp;gt;&lt;br /&gt;
http://www.ruby-doc.org/gems/docs/s/synergy_russian-0.2.8/I18n/Backend/Simple.html &amp;lt;br&amp;gt;&lt;br /&gt;
https://github.com/svenfuchs/i18n &amp;lt;br&amp;gt;&lt;br /&gt;
http://guides.rubyonrails.org/v2.3.11/i18n.html &amp;lt;br&amp;gt;&lt;br /&gt;
http://www.slideshare.net/Belighted/internationalization-in-rails-22-3120853 &amp;lt;br&amp;gt;&lt;br /&gt;
http://www.slideshare.net/graysky/rails-internationalization &amp;lt;br&amp;gt;&lt;br /&gt;
http://www.slideshare.net/ &amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Srparadk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w18_bs&amp;diff=76942</id>
		<title>CSC/ECE 517 Fall 2013/ch1 1w18 bs</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w18_bs&amp;diff=76942"/>
		<updated>2013-09-17T18:56:46Z</updated>

		<summary type="html">&lt;p&gt;Srparadk: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Internationalization in Rails&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
:In general when we start a conversation, the first default language of communication we use is English, but if the other person is not familiar with English we try and translate our dialogue in a language that the person is familiar with. Similarly whenever we write a program or a document we write it in English by default. But what if someone who is not familiar with English wants to read your program or code? The simple solution is that we translate program or code into a language that the person is familiar with. And for this, we use a term called internationalization.&lt;br /&gt;
&lt;br /&gt;
:Internationalization is a way by which we can view an application in various languages without actually making changes to the code of the application. This saves us a lot of time and effort, as we don’t have to write or edit the same code or document in all the copies.&lt;br /&gt;
&lt;br /&gt;
:Internationalization has an acronym, rather more of a numeronym ,which is i18n where the number 18 represents the number of letters between the first and last letters in the word internationalization.&lt;br /&gt;
&lt;br /&gt;
== Aspects to consider in Internationalization ==&lt;br /&gt;
&lt;br /&gt;
:Now when we are to change our application according to a particular language or a region , we need to keep in mind numerous points that are important, implicit, particular or sensitive to that language or region. Like for example when we take a language into consideration for which our application needs to be translated, we need to consider the spoken and written aspects of that language. Also, there might be a case when we have the same language but it differs from one region to other. For this we need to keep in mind the typical change in the use of words, grammar and symbol for each region that uses the same language. Our application must also provide support for the varied writing conventions that differ from a language to another language or from one region to another.&lt;br /&gt;
&lt;br /&gt;
:Below are the examples of the points we need to keep in mind while we provide internationalization to our application :&lt;br /&gt;
&lt;br /&gt;
* Language :&lt;br /&gt;
&lt;br /&gt;
:Here the i18n support to an application needs to provide the character encoding keeping in mind the following points:&lt;br /&gt;
&lt;br /&gt;
#The written language differs. For example most of the languages like English, French, German follow a script that can have inputs from a standard keyboard. But there are other languages like Hindi, Marathi, Sanskrit that follow a script called Devnagri and this cannot be directly typed in from a standard keyboard. So if we have to provide support for these languages we need to support the translation of the characters used in these scripts.&lt;br /&gt;
#The way we write also differs and needs to included in our i18n support. For example most of the languages follow a left-right direction while writing but some languages like Urdu tend to follow a right-left direction.&lt;br /&gt;
#The numbering symbols also vary from language to language. So when we display or accept any text with numbers, we must have i18n to support this mapping.&lt;br /&gt;
#The languages also differ in the use of grammar and structure of the sentences.For example the grammar rules and structure formation in English is way different than the one followed by another language like Sanskrit.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Culture and Writing Conventions:&lt;br /&gt;
&lt;br /&gt;
:Even if the language with the same characters and grammar is used, the use of the language , the symbols , the way of writing and many other things change with change in the region.&lt;br /&gt;
:Following are some of the examples:&lt;br /&gt;
&lt;br /&gt;
#There are some cultures that have some regulations about having a middle name as father’s name but other cultures don’t necessary include the middle name.&lt;br /&gt;
#There might be cases when there are different names or terminologies used in different cultures for the same purpose. For example, to identify a citizen uniquely US has the system of SSN while India is in the process of implementing this by using the term as Aadhar number.&lt;br /&gt;
#Another example of difference in the writing convention can be taken as that of a postal code. Some countries have 6 digit postal codes while others have 5.&lt;br /&gt;
#There is a difference in the use of many other things like the currency(like INR,dollars,Euro) used, the symbols(€,$,₹) used , the units in which the weights , temperature are measured. Another example could be the use of lakhs , crores for mentioning any financial figures in some countries while others use millions, billions.&lt;br /&gt;
#There could also be a difference in the formats used for a same thing. For example the format of writing dates and times vary from one region to another.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* We also have to be careful that we cover all the sensitive topics and issues particular to a language or region.&lt;br /&gt;
&lt;br /&gt;
:Similarly there are many other factors that we need to take care of when we support internationalization for a particular language in a particular region.&lt;br /&gt;
&lt;br /&gt;
= Internationalization in Rails =&lt;br /&gt;
&lt;br /&gt;
:Internationalization support was extended from Rails version 2.2. So in order to internationalize a rails application, it has to be migrated :to Rails 2.2 or above. Every static string in the Rails framework — e.g. Active Record validation messages, time and date formats — have :been internationalized.&lt;br /&gt;
&lt;br /&gt;
:Following needs to be done in order to internationalize a rails application:&lt;br /&gt;
:#Ensure support for internationalization by migrating to appropriate version of rails if needed.&lt;br /&gt;
:#Tell rails where to find the appropriate translations files&lt;br /&gt;
:#Tell rails how to switch locales&lt;br /&gt;
&lt;br /&gt;
::YAML (.yml) or plain Ruby (.rb) files are used for storing translations.&lt;br /&gt;
&lt;br /&gt;
== History ==&lt;br /&gt;
&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100pt&amp;quot;| Ruby 2.2    || Internationalization support was extended from this version of Rails.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 2.3    || Additional feature for Localized Views was added in this version. The view files were rendered with an extension of the locale name.I18n#available_locales and I18n::SimpleBackend#available_locales is available to retrieve an array of available locales.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 3.0    || Some additional features were added to the I18n gem for speed improvements like default translations for attributes,automatic pull for translations on form submit, etc.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 3.1    || I18n namespace lookup support removed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Ways to configure Internationalization in Rails ==&lt;br /&gt;
&lt;br /&gt;
:We can set up a rails application to support internationalization in a number of ways. Below are the various ways to configure our rails application for internationalization.&lt;br /&gt;
&lt;br /&gt;
#'''Configure the I18n module:'''&amp;lt;br&amp;gt;Rails adds all .rb and .yml files from the config/locales directory to your translations load path, automatically. This is the default setting provided by the [https://github.com/svenfuchs/i18n I18n gem]. In order to override this setting we have to make changes in the application.rb files that have instructions on how to add locales from another directory and how to set a different default locale.&lt;br /&gt;
#'''Custom I18n Configuration Setup:'''&amp;lt;br&amp;gt;Optionally, the above code can be placed anywhere in the application preferably in initializers.&lt;br /&gt;
#'''Setting and passing locale:'''&amp;lt;br&amp;gt;The above two steps help setup a default locale throughout the application. But in case we have to provide our application in different languages, we can setup the application default locale in the application.rb and then set the locale using the application-controller.rb before_action. We can then pass the locale we want as a query param for example http://study.com/books?locale=es&lt;br /&gt;
#'''Setting the locale from the domain name:'''&amp;lt;br&amp;gt;Similar to option 3 but instead of passing the locale as a query param, the locale is a part of the domain name itself. Example http://study.es&lt;br /&gt;
::You can implement it like this in your ApplicationController before_action&lt;br /&gt;
#'''Setting the locale from the URL params:'''&amp;lt;br&amp;gt;&lt;br /&gt;
##This can be a tedious task as we have to pass the locale on each request. &lt;br /&gt;
##Rails provides us an alternative for &amp;quot;centralizing dynamic decisions about the URLs&amp;quot; in its ApplicationController#default_url_options and helper methods are dependent on it (by implementing/overriding this method). This will now automatically include the locale param in the query string&lt;br /&gt;
##We can also set the locale in the URL route. For example -http://study.com/es/books .This is achievable by using over-riding default_url_options. You just have to set up your routes with scoping option in routes.rb. &lt;br /&gt;
#'''Setting the locale from client supplied information:'''&amp;lt;br&amp;gt;This can be done in 3 ways&lt;br /&gt;
##Using the default locale of the client browser&lt;br /&gt;
##Using client location to select the locale&lt;br /&gt;
##Saving the users choice of locale as a part of user profile&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Internationalizing Rails application ==&lt;br /&gt;
&lt;br /&gt;
:After your application is prepared for internationalization, we need to use the feature in our application. &lt;br /&gt;
:This can be done in the following ways:&lt;br /&gt;
&lt;br /&gt;
1. '''Adding Translations:'''&lt;br /&gt;
:In order to internationalize rails code, replace the strings with calls to  the ‘t’ helper.&amp;lt;br&amp;gt;For example: &lt;br /&gt;
 class HelloWorld &lt;br /&gt;
  def sayHello&lt;br /&gt;
    puts t(:hello_world)&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;%=t :hello_world %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:The helper method t also catches missing translations and displays appropriate error message.&lt;br /&gt;
 &amp;lt;nowiki /&amp;gt;# config/locales/en.yml&lt;br /&gt;
 en: hello_world: Hello world!&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki /&amp;gt;# config/locales/es.yml&lt;br /&gt;
 es: hello_world: hola mundo&lt;br /&gt;
&lt;br /&gt;
2. '''Passing variables to translation:'''&lt;br /&gt;
:You can use variables in the translation messages and pass their values from the view.&lt;br /&gt;
 en:&lt;br /&gt;
 portal: &amp;quot;Mypack&amp;quot;&lt;br /&gt;
   university:&lt;br /&gt;
    ncsu:&lt;br /&gt;
    description: ! 'NCSU student information is accessed on %{portal_name}’ &lt;br /&gt;
&lt;br /&gt;
 t('.description', portal_name: t(‘portal’))&lt;br /&gt;
&lt;br /&gt;
3. '''Adding date/ time formats:'''&lt;br /&gt;
:OK! Now let's add a timestamp to the view, so we can demo the date/time localization feature as well. To localize the time format you pass the Time object to I18n.l or (preferably) use ‘l’ helper. You can pick a format by passing the :format option — by default the :default format is used.&lt;br /&gt;
:In the view file:&lt;br /&gt;
 &amp;lt;%= l Time.now, format: :short %&amp;gt;&lt;br /&gt;
:In the yml file:&lt;br /&gt;
  es:&lt;br /&gt;
   time:&lt;br /&gt;
     formats:&lt;br /&gt;
       short: &amp;quot; Son las %H&amp;quot;&lt;br /&gt;
&lt;br /&gt;
4. '''Inflection rules for locales other than english:'''&lt;br /&gt;
:Rails 4.0 provides a feature to define inflection rules (singularization and pluralization)  in config/initializers/inflections.rb. &lt;br /&gt;
&lt;br /&gt;
5. '''Localized views:'''&lt;br /&gt;
:For static websites available in different languages or for large static content, localized views is a useful feature. This feature enables having separate view file for different locales. For example for default locale we can have show.html.erb file while for Spanish we can have show.es.html.erb. Thus we don’t need to maintain long .yml files for each supported locale for long static pages.&lt;br /&gt;
&lt;br /&gt;
== Internationalization Features ==&lt;br /&gt;
&lt;br /&gt;
1. '''Using Different Backends:'''&lt;br /&gt;
:The i18n provides a [http://www.ruby-doc.org/gems/docs/s/synergy_russian-0.2.8/I18n/Backend/Simple.html simple backend] by default. We can change the backend to an active records backend or chain multiple backends as per the requirements of our application. I18n gem also provides cache, fallback and pluralization feature for the backends.&lt;br /&gt;
&lt;br /&gt;
2. '''Pluralization:'''&lt;br /&gt;
:Different languages have different rules for pluralization. Thus, the I18n API provides a flexible pluralization feature.&lt;br /&gt;
&lt;br /&gt;
3. '''Fallbacks:'''&lt;br /&gt;
:In case translation for a certain  locale is missing we can define fallback chain for the locales.&lt;br /&gt;
:For example we can define a fallback chain of the form &lt;br /&gt;
 :'en-CA' =&amp;gt; :'en-US', :'en-US' =&amp;gt; :en, :de =&amp;gt; :en &lt;br /&gt;
&lt;br /&gt;
:if the translation for en-CA is missing rails looks for en-US , if en-US is missing it then looks for en and so on.&lt;br /&gt;
&lt;br /&gt;
4. '''Cascading lookups:'''&lt;br /&gt;
:If a given key is not found, it is broken and a lookup is performed for the remaining portion of the key before finally falling back to the defaults.&lt;br /&gt;
&lt;br /&gt;
5. '''Translation symlinks:'''&lt;br /&gt;
:A key can be a value for another key.&lt;br /&gt;
:Example:&lt;br /&gt;
 person: ‘ash’&lt;br /&gt;
 student: :person&lt;br /&gt;
 employee: :person&lt;br /&gt;
&lt;br /&gt;
:Ash can be an employee or a student. Each key represents the same value.&lt;br /&gt;
&lt;br /&gt;
6. '''Translation procs:'''&lt;br /&gt;
:I18n gem allows writing translation logic in the translation lookup process.&lt;br /&gt;
:For example:&lt;br /&gt;
 :en&lt;br /&gt;
  	:addressing =&amp;gt; lambda { |values|&lt;br /&gt;
 		person=values[:person]&lt;br /&gt;
 		address=person.male? ?  “Sir” : “Madam”&lt;br /&gt;
 	“Hello, #{person.address}”&lt;br /&gt;
 &lt;br /&gt;
 t(:addressing , :person =&amp;gt; mary)&lt;br /&gt;
&lt;br /&gt;
= Advantages of Internationalization = &lt;br /&gt;
&lt;br /&gt;
#Internationalization opens up a whole new market for applications. For example, consider a website which has support for internationalization and because of that it can be displayed in a number of languages. This opens a lot of new markets, business opportunities and a large number of potential customers.&lt;br /&gt;
#With the help of the internationalization gem, the application code has been simplified.&lt;br /&gt;
#The maintenance of the code is also made easy.  Also, the steps to add support to a new language are quite simple. &lt;br /&gt;
#Internationalization in rails(i18n gem) provides a variety of ways to incorporate internationalization in our application. This makes it easier for the developer to adopt a method that suits his application. For example, for a static application we can we one configuration technique and say for a dynamic application we can follow another configuration method for internationalization.&lt;br /&gt;
&lt;br /&gt;
= Internationalization in PHP, Java =&lt;br /&gt;
== Internationalization in PHP ==&lt;br /&gt;
&lt;br /&gt;
:In PHP, we need to install/enable extensions to support internationalization(not required with PHP 5.3.0 version). For building the internationalization tool we must have  ICU library (v 3.6 or more). &lt;br /&gt;
:The internationalization in PHP is provided by modules which are built with the internationalization extension. PHP applies i18n in one of the following ways:&lt;br /&gt;
#'''Using Object-Oriented API :''' &lt;br /&gt;
:This makes of the object-oriented API provided by the modules. This method represents the modules in the form of classes.&lt;br /&gt;
#'''Using Procedural API :'''&lt;br /&gt;
:This makes use of the procedural API provided by the modules. This method represents the modules in the form of a group of functions.&lt;br /&gt;
:Note: Each module provided both of the above API’s.&lt;br /&gt;
:Each of these modules provide different functionality of internationalization. For example PHP has modules like:&lt;br /&gt;
&lt;br /&gt;
#'''Locale''' —  This mainly deals with breaking and assembling of strings from components and displaying them in a specified locale.&lt;br /&gt;
#'''Collator''' —  This maily deals with comparison and sorting of strings according to the rules of the specified locale.&lt;br /&gt;
#'''Number formatter''' — This mainly deals with formatting number in a specific way according to a locale and also parses textual representations of numbers.&lt;br /&gt;
#'''Date formatter''' —  This formats dates in accordance to the specified locale.&lt;br /&gt;
:and many more… &lt;br /&gt;
&lt;br /&gt;
:PHP also has specific functions who return internationalization errors. These functions serve all the available modules.&lt;br /&gt;
&lt;br /&gt;
== Comparison with Ruby : ==&lt;br /&gt;
&lt;br /&gt;
#Internationalization in PHP is a bit easy as compared to ruby. Because the way to implement internationalization is very similar to creating an object of a class and then using one of the functions of the classes. And hence the programmer is familiar with the syntax.&lt;br /&gt;
#Whenever we need to add more features to internationalization, in PHP we just have to add a module to the internationalization extension.&lt;br /&gt;
#In PHP, we have functions that are written specifically to return internationalization errors. This helps in making debugging easy in case i18n fails. In ruby we don’t have such dedicated functions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
http://guides.rubyonrails.org/3_0_release_notes.html &amp;lt;br&amp;gt;&lt;br /&gt;
http://rubylearning.com/blog/2012/07/24/minimal-i18n-with-rails-3-2/ &amp;lt;br&amp;gt;&lt;br /&gt;
http://blog.lingohub.com/developers/2013/08/internationalization-for-ruby-i18n-gem/ &amp;lt;br&amp;gt;&lt;br /&gt;
http://vimeo.com/12665914 &amp;lt;br&amp;gt;&lt;br /&gt;
http://www.artweb-design.de/2009/7/19/experimental-extensions-in-i18n-pluralization-fallbacks-gettext-cache-and-chain &amp;lt;br&amp;gt;&lt;br /&gt;
http://asciicasts.com/episodes/256-i18n-backends &amp;lt;br&amp;gt;&lt;br /&gt;
http://blog.lingohub.com/developers/2013/08/i18n-gem-advanced-features-ruby-rails-internationalization/ &amp;lt;br&amp;gt;&lt;br /&gt;
http://en.wikipedia.org/wiki/Internationalization_and_localization &amp;lt;br&amp;gt;&lt;br /&gt;
http://www.ruby-doc.org/gems/docs/s/synergy_russian-0.2.8/I18n/Backend/Simple.html &amp;lt;br&amp;gt;&lt;br /&gt;
https://github.com/svenfuchs/i18n &amp;lt;br&amp;gt;&lt;br /&gt;
http://guides.rubyonrails.org/v2.3.11/i18n.html &amp;lt;br&amp;gt;&lt;br /&gt;
http://www.slideshare.net/Belighted/internationalization-in-rails-22-3120853 &amp;lt;br&amp;gt;&lt;br /&gt;
http://www.slideshare.net/graysky/rails-internationalization &amp;lt;br&amp;gt;&lt;br /&gt;
http://www.slideshare.net/ &amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Srparadk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w18_bs&amp;diff=76131</id>
		<title>CSC/ECE 517 Fall 2013/ch1 1w18 bs</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w18_bs&amp;diff=76131"/>
		<updated>2013-09-16T21:23:23Z</updated>

		<summary type="html">&lt;p&gt;Srparadk: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Internationalization in Rails&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
:In general when we start a conversation, the first default language of communication we use is English, but if the other person is not familiar with English we try and translate our dialogue in a language that the person is familiar with. Similarly whenever we write a program or a document we write it in English by default. But what if someone who is not familiar with English wants to read your program or code? The simple solution is that we translate program or code into a language that the person is familiar with. And for this, we use a term called internationalization.&lt;br /&gt;
&lt;br /&gt;
:Internationalization is a way by which we can view an application in various languages without actually making changes to the code of the application. This saves us a lot of time and effort, as we don’t have to write or edit the same code or document in all the copies.&lt;br /&gt;
&lt;br /&gt;
:Internationalization has an acronym, rather more of a numeronym ,which is i18n where the number 18 represents the number of letters between the first and last letters in the word internationalization.&lt;br /&gt;
&lt;br /&gt;
== Aspects to consider in Internationalization ==&lt;br /&gt;
&lt;br /&gt;
:Now when we are to change our application according to a particular language or a region , we need to keep in mind numerous points that are important, implicit, particular or sensitive to that language or region. Like for example when we take a language into consideration for which our application needs to be translated, we need to consider the spoken and written aspects of that language. Also, there might be a case when we have the same language but it differs from one region to other. For this we need to keep in mind the typical change in the use of words, grammar and symbol for each region that uses the same language. Our application must also provide support for the varied writing conventions that differ from a language to another language or from one region to another.&lt;br /&gt;
&lt;br /&gt;
:Below are the examples of the points we need to keep in mind while we provide internationalization to our application :&lt;br /&gt;
&lt;br /&gt;
* Language :&lt;br /&gt;
&lt;br /&gt;
:Here the i18n support to an application needs to provide the character encoding keeping in mind the following points:&lt;br /&gt;
&lt;br /&gt;
#The written language differs. For example most of the languages like English, French, German follow a script that can have inputs from a standard keyboard. But there are other languages like Hindi, Marathi, Sanskrit that follow a script called Devnagri and this cannot be directly typed in from a standard keyboard. So if we have to provide support for these languages we need to support the translation of the characters used in these scripts.&lt;br /&gt;
#The way we write also differs and needs to included in our i18n support. For example most of the languages follow a left-right direction while writing but some languages like Urdu tend to follow a right-left direction.&lt;br /&gt;
#The numbering symbols also vary from language to language. So when we display or accept any text with numbers, we must have i18n to support this mapping.&lt;br /&gt;
#The languages also differ in the use of grammar and structure of the sentences.For example the grammar rules and structure formation in English is way different than the one followed by another language like Sanskrit.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Culture and Writing Conventions:&lt;br /&gt;
&lt;br /&gt;
:Even if the language with the same characters and grammar is used, the use of the language , the symbols , the way of writing and many other things change with change in the region.&lt;br /&gt;
:Following are some of the examples:&lt;br /&gt;
&lt;br /&gt;
#There are some cultures that have some regulations about having a middle name as father’s name but other cultures don’t necessary include the middle name.&lt;br /&gt;
#There might be cases when there are different names or terminologies used in different cultures for the same purpose. For example, to identify a citizen uniquely US has the system of SSN while India is in the process of implementing this by using the term as Aadhar number.&lt;br /&gt;
#Another example of difference in the writing convention can be taken as that of a postal code. Some countries have 6 digit postal codes while others have 5.&lt;br /&gt;
#There is a difference in the use of many other things like the currency(like INR,dollars,Euro) used, the symbols(€,$,₹) used , the units in which the weights , temperature are measured. Another example could be the use of lakhs , crores for mentioning any financial figures in some countries while others use millions, billions.&lt;br /&gt;
#There could also be a difference in the formats used for a same thing. For example the format of writing dates and times vary from one region to another.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* We also have to be careful that we cover all the sensitive topics and issues particular to a language or region.&lt;br /&gt;
&lt;br /&gt;
:Similarly there are many other factors that we need to take care of when we support internationalization for a particular language in a particular region.&lt;br /&gt;
&lt;br /&gt;
= Internationalization in Rails =&lt;br /&gt;
&lt;br /&gt;
:Internationalization support was extended from Rails version 2.2. So in order to internationalize a rails application, it has to be migrated :to Rails 2.2 or above. Every static string in the Rails framework — e.g. Active Record validation messages, time and date formats — have :been internationalized.&lt;br /&gt;
&lt;br /&gt;
:Following needs to be done in order to internationalize a rails application:&lt;br /&gt;
:#Ensure support for internationalization by migrating to appropriate version of rails if needed.&lt;br /&gt;
:#Tell rails where to find the appropriate translations files&lt;br /&gt;
:#Tell rails how to switch locales&lt;br /&gt;
&lt;br /&gt;
::YAML (.yml) or plain Ruby (.rb) files are used for storing translations.&lt;br /&gt;
&lt;br /&gt;
== History ==&lt;br /&gt;
&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100pt&amp;quot;| Ruby 2.2    || Internationalization support was extended from this version of Rails.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 2.3    || Additional feature for Localized Views was added in this version. The view files were rendered with an extension of the locale name.I18n#available_locales and I18n::SimpleBackend#available_locales is available to retrieve an array of available locales.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 3.0    || Some additional features were added to the I18n gem for speed improvements like default translations for attributes,automatic pull for translations on form submit, etc.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 3.1    || I18n namespace lookup support removed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Ways to configure Internationalization in Rails ==&lt;br /&gt;
&lt;br /&gt;
:We can set up a rails application to support internationalization in a number of ways. Below are the various ways to configure our rails application for internationalization.&lt;br /&gt;
&lt;br /&gt;
#'''Configure the I18n module:'''&amp;lt;br&amp;gt;Rails adds all .rb and .yml files from the config/locales directory to your translations load path, automatically. This is the default setting provided by the [https://github.com/svenfuchs/i18n I18n gem]. In order to override this setting we have to make changes in the application.rb files that have instructions on how to add locales from another directory and how to set a different default locale.&lt;br /&gt;
#'''Custom I18n Configuration Setup:'''&amp;lt;br&amp;gt;Optionally, the above code can be placed anywhere in the application preferably in initializers.&lt;br /&gt;
#'''Setting and passing locale:'''&amp;lt;br&amp;gt;The above two steps help setup a default locale throughout the application. But in case we have to provide our application in different languages, we can setup the application default locale in the application.rb and then set the locale using the application-controller.rb before_action. We can then pass the locale we want as a query param for example http://study.com/books?locale=es&lt;br /&gt;
#'''Setting the locale from the domain name:'''&amp;lt;br&amp;gt;Similar to option 3 but instead of passing the locale as a query param, the locale is a part of the domain name itself. Example http://study.es&lt;br /&gt;
::You can implement it like this in your ApplicationController before_action&lt;br /&gt;
#'''Setting the locale from the URL params:'''&amp;lt;br&amp;gt;&lt;br /&gt;
##This can be a tedious task as we have to pass the locale on each request. &lt;br /&gt;
##Rails provides us an alternative for &amp;quot;centralizing dynamic decisions about the URLs&amp;quot; in its ApplicationController#default_url_options and helper methods are dependent on it (by implementing/overriding this method). This will now automatically include the locale param in the query string&lt;br /&gt;
##We can also set the locale in the URL route. For example -http://study.com/es/books .This is achievable by using over-riding default_url_options. You just have to set up your routes with scoping option in routes.rb. &lt;br /&gt;
#'''Setting the locale from client supplied information:'''&amp;lt;br&amp;gt;This can be done in 3 ways&lt;br /&gt;
##Using the default locale of the client browser&lt;br /&gt;
##Using client location to select the locale&lt;br /&gt;
##Saving the users choice of locale as a part of user profile&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Internationalizing Rails application ==&lt;br /&gt;
&lt;br /&gt;
:After your application is prepared for internationalization, we need to use the feature in our application. &lt;br /&gt;
:This can be done in the following ways:&lt;br /&gt;
&lt;br /&gt;
1. '''Adding Translations:'''&lt;br /&gt;
:In order to internationalize rails code, replace the strings with calls to  the ‘t’ helper.&amp;lt;br&amp;gt;For example: &lt;br /&gt;
 class HelloWorld &lt;br /&gt;
  def sayHello&lt;br /&gt;
    puts t(:hello_world)&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;%=t :hello_world %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:The helper method t also catches missing translations and displays appropriate error message.&lt;br /&gt;
 &amp;lt;nowiki /&amp;gt;# config/locales/en.yml&lt;br /&gt;
 en: hello_world: Hello world!&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki /&amp;gt;# config/locales/es.yml&lt;br /&gt;
 es: hello_world: hola mundo&lt;br /&gt;
&lt;br /&gt;
2. '''Passing variables to translation:'''&lt;br /&gt;
:You can use variables in the translation messages and pass their values from the view.&lt;br /&gt;
 en:&lt;br /&gt;
 portal: &amp;quot;Mypack&amp;quot;&lt;br /&gt;
   university:&lt;br /&gt;
    ncsu:&lt;br /&gt;
    description: ! 'NCSU student information is accessed on %{portal_name}’ &lt;br /&gt;
&lt;br /&gt;
 t('.description', portal_name: t(‘portal’))&lt;br /&gt;
&lt;br /&gt;
3. '''Adding date/ time formats:'''&lt;br /&gt;
:OK! Now let's add a timestamp to the view, so we can demo the date/time localization feature as well. To localize the time format you pass the Time object to I18n.l or (preferably) use ‘l’ helper. You can pick a format by passing the :format option — by default the :default format is used.&lt;br /&gt;
:In the view file:&lt;br /&gt;
 &amp;lt;%= l Time.now, format: :short %&amp;gt;&lt;br /&gt;
:In the yml file:&lt;br /&gt;
  es:&lt;br /&gt;
   time:&lt;br /&gt;
     formats:&lt;br /&gt;
       short: &amp;quot; Son las %H&amp;quot;&lt;br /&gt;
&lt;br /&gt;
4. '''Inflection rules for locales other than english:'''&lt;br /&gt;
:Rails 4.0 provides a feature to define inflection rules (singularization and pluralization)  in config/initializers/inflections.rb. &lt;br /&gt;
&lt;br /&gt;
5. '''Localized views:'''&lt;br /&gt;
:For static websites available in different languages or for large static content, localized views is a useful feature. This feature enables having separate view file for different locales. For example for default locale we can have show.html.erb file while for Spanish we can have show.es.html.erb. Thus we don’t need to maintain long .yml files for each supported locale for long static pages.&lt;br /&gt;
&lt;br /&gt;
== Internationalization Features ==&lt;br /&gt;
&lt;br /&gt;
1. '''Using Different Backends:'''&lt;br /&gt;
:The i18n provides a [http://www.ruby-doc.org/gems/docs/s/synergy_russian-0.2.8/I18n/Backend/Simple.html simple backend] by default. We can change the backend to an active records backend or chain multiple backends as per the requirements of our application. I18n gem also provides cache, fallback and pluralization feature for the backends.&lt;br /&gt;
&lt;br /&gt;
2. '''Pluralization:'''&lt;br /&gt;
:Different languages have different rules for pluralization. Thus, the I18n API provides a flexible pluralization feature.&lt;br /&gt;
&lt;br /&gt;
3. '''Fallbacks:'''&lt;br /&gt;
:In case translation for a certain  locale is missing we can define fallback chain for the locales.&lt;br /&gt;
:For example we can define a fallback chain of the form &lt;br /&gt;
 :'en-CA' =&amp;gt; :'en-US', :'en-US' =&amp;gt; :en, :de =&amp;gt; :en &lt;br /&gt;
&lt;br /&gt;
:if the translation for en-CA is missing rails looks for en-US , if en-US is missing it then looks for en and so on.&lt;br /&gt;
&lt;br /&gt;
4. '''Cascading lookups:'''&lt;br /&gt;
:If a given key is not found, it is broken and a lookup is performed for the remaining portion of the key before finally falling back to the defaults.&lt;br /&gt;
&lt;br /&gt;
5. '''Translation symlinks:'''&lt;br /&gt;
:A key can be a value for another key.&lt;br /&gt;
:Example:&lt;br /&gt;
 person: ‘ash’&lt;br /&gt;
 student: :person&lt;br /&gt;
 employee: :person&lt;br /&gt;
&lt;br /&gt;
:Ash can be an employee or a student. Each key represents the same value.&lt;br /&gt;
&lt;br /&gt;
6. '''Translation procs:'''&lt;br /&gt;
:I18n gem allows writing translation logic in the translation lookup process.&lt;br /&gt;
:For example:&lt;br /&gt;
 :en&lt;br /&gt;
  	:addressing =&amp;gt; lambda { |values|&lt;br /&gt;
 		person=values[:person]&lt;br /&gt;
 		address=person.male? ?  “Sir” : “Madam”&lt;br /&gt;
 	“Hello, #{person.address}”&lt;br /&gt;
 &lt;br /&gt;
 t(:addressing , :person =&amp;gt; mary)&lt;br /&gt;
&lt;br /&gt;
= Advantages of Internationalization = &lt;br /&gt;
&lt;br /&gt;
#Internationalization opens up a whole new market for applications. For example, consider a website which has support for internationalization and because of that it can be displayed in a number of languages. This opens a lot of new markets, business opportunities and a large number of potential customers.&lt;br /&gt;
#With the help of the internationalization gem, the application code has been simplified.&lt;br /&gt;
#The maintenance of the code is also made easy.  Also, the steps to add support to a new language are quite simple. &lt;br /&gt;
#Internationalization in rails(i18n gem) provides a variety of ways to incorporate internationalization in our application. This makes it easier for the developer to adopt a method that suits his application. For example, for a static application we can we one configuration technique and say for a dynamic application we can follow another configuration method for internationalization.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
http://guides.rubyonrails.org/3_0_release_notes.html &amp;lt;br&amp;gt;&lt;br /&gt;
http://rubylearning.com/blog/2012/07/24/minimal-i18n-with-rails-3-2/ &amp;lt;br&amp;gt;&lt;br /&gt;
http://blog.lingohub.com/developers/2013/08/internationalization-for-ruby-i18n-gem/ &amp;lt;br&amp;gt;&lt;br /&gt;
http://vimeo.com/12665914 &amp;lt;br&amp;gt;&lt;br /&gt;
http://www.artweb-design.de/2009/7/19/experimental-extensions-in-i18n-pluralization-fallbacks-gettext-cache-and-chain &amp;lt;br&amp;gt;&lt;br /&gt;
http://asciicasts.com/episodes/256-i18n-backends &amp;lt;br&amp;gt;&lt;br /&gt;
http://blog.lingohub.com/developers/2013/08/i18n-gem-advanced-features-ruby-rails-internationalization/ &amp;lt;br&amp;gt;&lt;br /&gt;
http://en.wikipedia.org/wiki/Internationalization_and_localization &amp;lt;br&amp;gt;&lt;br /&gt;
http://www.ruby-doc.org/gems/docs/s/synergy_russian-0.2.8/I18n/Backend/Simple.html &amp;lt;br&amp;gt;&lt;br /&gt;
https://github.com/svenfuchs/i18n &amp;lt;br&amp;gt;&lt;br /&gt;
http://guides.rubyonrails.org/v2.3.11/i18n.html &amp;lt;br&amp;gt;&lt;br /&gt;
http://www.slideshare.net/Belighted/internationalization-in-rails-22-3120853 &amp;lt;br&amp;gt;&lt;br /&gt;
http://www.slideshare.net/graysky/rails-internationalization &amp;lt;br&amp;gt;&lt;br /&gt;
http://www.slideshare.net/ &amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Srparadk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w18_bs&amp;diff=76130</id>
		<title>CSC/ECE 517 Fall 2013/ch1 1w18 bs</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w18_bs&amp;diff=76130"/>
		<updated>2013-09-16T21:16:46Z</updated>

		<summary type="html">&lt;p&gt;Srparadk: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Internationalization in Rails&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
:In general when we start a conversation, the first default language of communication we use is English, but if the other person is not familiar with English we try and translate our dialogue in a language that the person is familiar with. Similarly whenever we write a program or a document we write it in English by default. But what if someone who is not familiar with English wants to read your program or code? The simple solution is that we translate program or code into a language that the person is familiar with. And for this, we use a term called internationalization.&lt;br /&gt;
&lt;br /&gt;
:Internationalization is a way by which we can view an application in various languages without actually making changes to the code of the application. This saves us a lot of time and effort, as we don’t have to write or edit the same code or document in all the copies.&lt;br /&gt;
&lt;br /&gt;
:Internationalization has an acronym, rather more of a numeronym ,which is i18n where the number 18 represents the number of letters between the first and last letters in the word internationalization.&lt;br /&gt;
&lt;br /&gt;
== Aspects to consider in Internationalization ==&lt;br /&gt;
&lt;br /&gt;
:Now when we are to change our application according to a particular language or a region , we need to keep in mind numerous points that are important, implicit, particular or sensitive to that language or region. Like for example when we take a language into consideration for which our application needs to be translated, we need to consider the spoken and written aspects of that language. Also, there might be a case when we have the same language but it differs from one region to other. For this we need to keep in mind the typical change in the use of words, grammar and symbol for each region that uses the same language. Our application must also provide support for the varied writing conventions that differ from a language to another language or from one region to another.&lt;br /&gt;
&lt;br /&gt;
:Below are the examples of the points we need to keep in mind while we provide internationalization to our application :&lt;br /&gt;
&lt;br /&gt;
* Language :&lt;br /&gt;
&lt;br /&gt;
:Here the i18n support to an application needs to provide the character encoding keeping in mind the following points:&lt;br /&gt;
&lt;br /&gt;
#The written language differs. For example most of the languages like English, French, German follow a script that can have inputs from a standard keyboard. But there are other languages like Hindi, Marathi, Sanskrit that follow a script called Devnagri and this cannot be directly typed in from a standard keyboard. So if we have to provide support for these languages we need to support the translation of the characters used in these scripts.&lt;br /&gt;
#The way we write also differs and needs to included in our i18n support. For example most of the languages follow a left-right direction while writing but some languages like Urdu tend to follow a right-left direction.&lt;br /&gt;
#The numbering symbols also vary from language to language. So when we display or accept any text with numbers, we must have i18n to support this mapping.&lt;br /&gt;
#The languages also differ in the use of grammar and structure of the sentences.For example the grammar rules and structure formation in English is way different than the one followed by another language like Sanskrit.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Culture and Writing Conventions:&lt;br /&gt;
&lt;br /&gt;
:Even if the language with the same characters and grammar is used, the use of the language , the symbols , the way of writing and many other things change with change in the region.&lt;br /&gt;
:Following are some of the examples:&lt;br /&gt;
&lt;br /&gt;
#There are some cultures that have some regulations about having a middle name as father’s name but other cultures don’t necessary include the middle name.&lt;br /&gt;
#There might be cases when there are different names or terminologies used in different cultures for the same purpose. For example, to identify a citizen uniquely US has the system of SSN while India is in the process of implementing this by using the term as Aadhar number.&lt;br /&gt;
#Another example of difference in the writing convention can be taken as that of a postal code. Some countries have 6 digit postal codes while others have 5.&lt;br /&gt;
#There is a difference in the use of many other things like the currency(like INR,dollars,Euro) used, the symbols(€,$,₹) used , the units in which the weights , temperature are measured. Another example could be the use of lakhs , crores for mentioning any financial figures in some countries while others use millions, billions.&lt;br /&gt;
#There could also be a difference in the formats used for a same thing. For example the format of writing dates and times vary from one region to another.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* We also have to be careful that we cover all the sensitive topics and issues particular to a language or region.&lt;br /&gt;
&lt;br /&gt;
:Similarly there are many other factors that we need to take care of when we support internationalization for a particular language in a particular region.&lt;br /&gt;
&lt;br /&gt;
= Internationalization in Rails =&lt;br /&gt;
&lt;br /&gt;
:Internationalization support was extended from Rails version 2.2. So in order to internationalize a rails application, it has to be migrated :to Rails 2.2 or above. Every static string in the Rails framework — e.g. Active Record validation messages, time and date formats — have :been internationalized.&lt;br /&gt;
&lt;br /&gt;
:Following needs to be done in order to internationalize a rails application:&lt;br /&gt;
:#Ensure support for internationalization by migrating to appropriate version of rails if needed.&lt;br /&gt;
:#Tell rails where to find the appropriate translations files&lt;br /&gt;
:#Tell rails how to switch locales&lt;br /&gt;
&lt;br /&gt;
::YAML (.yml) or plain Ruby (.rb) files are used for storing translations.&lt;br /&gt;
&lt;br /&gt;
== History ==&lt;br /&gt;
&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100pt&amp;quot;| Ruby 2.2    || Internationalization support was extended from this version of Rails.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 2.3    || Additional feature for Localized Views was added in this version. The view files were rendered with an extension of the locale name.I18n#available_locales and I18n::SimpleBackend#available_locales is available to retrieve an array of available locales.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 3.0    || Some additional features were added to the I18n gem for speed improvements like default translations for attributes,automatic pull for translations on form submit, etc.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 3.1    || I18n namespace lookup support removed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Ways to configure Internationalization in Rails ==&lt;br /&gt;
&lt;br /&gt;
:We can set up a rails application to support internationalization in a number of ways. Below are the various ways to configure our rails application for internationalization.&lt;br /&gt;
&lt;br /&gt;
#'''Configure the I18n module:'''&amp;lt;br&amp;gt;Rails adds all .rb and .yml files from the config/locales directory to your translations load path, automatically. This is the default setting provided by the [https://github.com/svenfuchs/i18n I18n gem]. In order to override this setting we have to make changes in the application.rb files that have instructions on how to add locales from another directory and how to set a different default locale.&lt;br /&gt;
#'''Custom I18n Configuration Setup:'''&amp;lt;br&amp;gt;Optionally, the above code can be placed anywhere in the application preferably in initializers.&lt;br /&gt;
#'''Setting and passing locale:'''&amp;lt;br&amp;gt;The above two steps help setup a default locale throughout the application. But in case we have to provide our application in different languages, we can setup the application default locale in the application.rb and then set the locale using the application-controller.rb before_action. We can then pass the locale we want as a query param for example http://study.com/books?locale=es&lt;br /&gt;
#'''Setting the locale from the domain name:'''&amp;lt;br&amp;gt;Similar to option 3 but instead of passing the locale as a query param, the locale is a part of the domain name itself. Example http://study.es&lt;br /&gt;
::You can implement it like this in your ApplicationController before_action&lt;br /&gt;
#'''Setting the locale from the URL params:'''&amp;lt;br&amp;gt;&lt;br /&gt;
##This can be a tedious task as we have to pass the locale on each request. &lt;br /&gt;
##Rails provides us an alternative for &amp;quot;centralizing dynamic decisions about the URLs&amp;quot; in its ApplicationController#default_url_options and helper methods are dependent on it (by implementing/overriding this method). This will now automatically include the locale param in the query string&lt;br /&gt;
##We can also set the locale in the URL route. For example -http://study.com/es/books .This is achievable by using over-riding default_url_options. You just have to set up your routes with scoping option in routes.rb. &lt;br /&gt;
#'''Setting the locale from client supplied information:'''&amp;lt;br&amp;gt;This can be done in 3 ways&lt;br /&gt;
##Using the default locale of the client browser&lt;br /&gt;
##Using client location to select the locale&lt;br /&gt;
##Saving the users choice of locale as a part of user profile&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Internationalizing Rails application ==&lt;br /&gt;
&lt;br /&gt;
:After your application is prepared for internationalization, we need to use the feature in our application. &lt;br /&gt;
:This can be done in the following ways:&lt;br /&gt;
&lt;br /&gt;
1. '''Adding Translations:'''&lt;br /&gt;
:In order to internationalize rails code, replace the strings with calls to  the ‘t’ helper.&amp;lt;br&amp;gt;For example: &lt;br /&gt;
 class HelloWorld &lt;br /&gt;
  def sayHello&lt;br /&gt;
    puts t(:hello_world)&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;%=t :hello_world %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:The helper method t also catches missing translations and displays appropriate error message.&lt;br /&gt;
 &amp;lt;nowiki /&amp;gt;# config/locales/en.yml&lt;br /&gt;
 en: hello_world: Hello world!&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki /&amp;gt;# config/locales/es.yml&lt;br /&gt;
 es: hello_world: hola mundo&lt;br /&gt;
&lt;br /&gt;
2. '''Passing variables to translation:'''&lt;br /&gt;
:You can use variables in the translation messages and pass their values from the view.&lt;br /&gt;
 en:&lt;br /&gt;
 portal: &amp;quot;Mypack&amp;quot;&lt;br /&gt;
   university:&lt;br /&gt;
    ncsu:&lt;br /&gt;
    description: ! 'NCSU student information is accessed on %{portal_name}’ &lt;br /&gt;
&lt;br /&gt;
 t('.description', portal_name: t(‘portal’))&lt;br /&gt;
&lt;br /&gt;
3. '''Adding date/ time formats:'''&lt;br /&gt;
:OK! Now let's add a timestamp to the view, so we can demo the date/time localization feature as well. To localize the time format you pass the Time object to I18n.l or (preferably) use ‘l’ helper. You can pick a format by passing the :format option — by default the :default format is used.&lt;br /&gt;
:In the view file:&lt;br /&gt;
 &amp;lt;%= l Time.now, format: :short %&amp;gt;&lt;br /&gt;
:In the yml file:&lt;br /&gt;
  es:&lt;br /&gt;
   time:&lt;br /&gt;
     formats:&lt;br /&gt;
       short: &amp;quot; Son las %H&amp;quot;&lt;br /&gt;
&lt;br /&gt;
4. '''Inflection rules for locales other than english:'''&lt;br /&gt;
:Rails 4.0 provides a feature to define inflection rules (singularization and pluralization)  in config/initializers/inflections.rb. &lt;br /&gt;
&lt;br /&gt;
5. '''Localized views:'''&lt;br /&gt;
:For static websites available in different languages or for large static content, localized views is a useful feature. This feature enables having separate view file for different locales. For example for default locale we can have show.html.erb file while for Spanish we can have show.es.html.erb. Thus we don’t need to maintain long .yml files for each supported locale for long static pages.&lt;br /&gt;
&lt;br /&gt;
== Internationalization Features ==&lt;br /&gt;
&lt;br /&gt;
1. '''Using Different Backends:'''&lt;br /&gt;
:The i18n provides a [http://www.ruby-doc.org/gems/docs/s/synergy_russian-0.2.8/I18n/Backend/Simple.html simple backend] by default. We can change the backend to an active records backend or chain multiple backends as per the requirements of our application. I18n gem also provides cache, fallback and pluralization feature for the backends.&lt;br /&gt;
&lt;br /&gt;
2. '''Pluralization:'''&lt;br /&gt;
:Different languages have different rules for pluralization. Thus, the I18n API provides a flexible pluralization feature.&lt;br /&gt;
&lt;br /&gt;
3. '''Fallbacks:'''&lt;br /&gt;
:In case translation for a certain  locale is missing we can define fallback chain for the locales.&lt;br /&gt;
:For example we can define a fallback chain of the form &lt;br /&gt;
 :'en-CA' =&amp;gt; :'en-US', :'en-US' =&amp;gt; :en, :de =&amp;gt; :en &lt;br /&gt;
&lt;br /&gt;
:if the translation for en-CA is missing rails looks for en-US , if en-US is missing it then looks for en and so on.&lt;br /&gt;
&lt;br /&gt;
4. '''Cascading lookups:'''&lt;br /&gt;
:If a given key is not found, it is broken and a lookup is performed for the remaining portion of the key before finally falling back to the defaults.&lt;br /&gt;
&lt;br /&gt;
5. '''Translation symlinks:'''&lt;br /&gt;
:A key can be a value for another key.&lt;br /&gt;
:Example:&lt;br /&gt;
 person: ‘ash’&lt;br /&gt;
 student: :person&lt;br /&gt;
 employee: :person&lt;br /&gt;
&lt;br /&gt;
:Ash can be an employee or a student. Each key represents the same value.&lt;br /&gt;
&lt;br /&gt;
6. '''Translation procs:'''&lt;br /&gt;
:I18n gem allows writing translation logic in the translation lookup process.&lt;br /&gt;
:For example:&lt;br /&gt;
 :en&lt;br /&gt;
  	:addressing =&amp;gt; lambda { |values|&lt;br /&gt;
 		person=values[:person]&lt;br /&gt;
 		address=person.male? ?  “Sir” : “Madam”&lt;br /&gt;
 	“Hello, #{person.address}”&lt;br /&gt;
 &lt;br /&gt;
 t(:addressing , :person =&amp;gt; mary)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
http://guides.rubyonrails.org/3_0_release_notes.html &amp;lt;br&amp;gt;&lt;br /&gt;
http://rubylearning.com/blog/2012/07/24/minimal-i18n-with-rails-3-2/ &amp;lt;br&amp;gt;&lt;br /&gt;
http://blog.lingohub.com/developers/2013/08/internationalization-for-ruby-i18n-gem/ &amp;lt;br&amp;gt;&lt;br /&gt;
http://vimeo.com/12665914 &amp;lt;br&amp;gt;&lt;br /&gt;
http://www.artweb-design.de/2009/7/19/experimental-extensions-in-i18n-pluralization-fallbacks-gettext-cache-and-chain &amp;lt;br&amp;gt;&lt;br /&gt;
http://asciicasts.com/episodes/256-i18n-backends &amp;lt;br&amp;gt;&lt;br /&gt;
http://blog.lingohub.com/developers/2013/08/i18n-gem-advanced-features-ruby-rails-internationalization/ &amp;lt;br&amp;gt;&lt;br /&gt;
http://en.wikipedia.org/wiki/Internationalization_and_localization &amp;lt;br&amp;gt;&lt;br /&gt;
http://www.ruby-doc.org/gems/docs/s/synergy_russian-0.2.8/I18n/Backend/Simple.html &amp;lt;br&amp;gt;&lt;br /&gt;
https://github.com/svenfuchs/i18n &amp;lt;br&amp;gt;&lt;br /&gt;
http://guides.rubyonrails.org/v2.3.11/i18n.html &amp;lt;br&amp;gt;&lt;br /&gt;
http://www.slideshare.net/Belighted/internationalization-in-rails-22-3120853 &amp;lt;br&amp;gt;&lt;br /&gt;
http://www.slideshare.net/graysky/rails-internationalization &amp;lt;br&amp;gt;&lt;br /&gt;
http://www.slideshare.net/ &amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Srparadk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w18_bs&amp;diff=76129</id>
		<title>CSC/ECE 517 Fall 2013/ch1 1w18 bs</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w18_bs&amp;diff=76129"/>
		<updated>2013-09-16T21:14:20Z</updated>

		<summary type="html">&lt;p&gt;Srparadk: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Internationalization in Rails&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
:In general when we start a conversation, the first default language of communication we use is English, but if the other person is not familiar with English we try and translate our dialogue in a language that the person is familiar with. Similarly whenever we write a program or a document we write it in English by default. But what if someone who is not familiar with English wants to read your program or code? The simple solution is that we translate program or code into a language that the person is familiar with. And for this, we use a term called internationalization.&lt;br /&gt;
&lt;br /&gt;
:Internationalization is a way by which we can view an application in various languages without actually making changes to the code of the application. This saves us a lot of time and effort, as we don’t have to write or edit the same code or document in all the copies.&lt;br /&gt;
&lt;br /&gt;
:Internationalization has an acronym, rather more of a numeronym ,which is i18n where the number 18 represents the number of letters between the first and last letters in the word internationalization.&lt;br /&gt;
&lt;br /&gt;
== Aspects to consider in Internationalization ==&lt;br /&gt;
&lt;br /&gt;
:Now when we are to change our application according to a particular language or a region , we need to keep in mind numerous points that are important, implicit, particular or sensitive to that language or region. Like for example when we take a language into consideration for which our application needs to be translated, we need to consider the spoken and written aspects of that language. Also, there might be a case when we have the same language but it differs from one region to other. For this we need to keep in mind the typical change in the use of words, grammar and symbol for each region that uses the same language. Our application must also provide support for the varied writing conventions that differ from a language to another language or from one region to another.&lt;br /&gt;
&lt;br /&gt;
:Below are the examples of the points we need to keep in mind while we provide internationalization to our application :&lt;br /&gt;
&lt;br /&gt;
* Language :&lt;br /&gt;
&lt;br /&gt;
:Here the i18n support to an application needs to provide the character encoding keeping in mind the following points:&lt;br /&gt;
&lt;br /&gt;
#The written language differs. For example most of the languages like English, French, German follow a script that can have inputs from a standard keyboard. But there are other languages like Hindi, Marathi, Sanskrit that follow a script called Devnagri and this cannot be directly typed in from a standard keyboard. So if we have to provide support for these languages we need to support the translation of the characters used in these scripts.&lt;br /&gt;
#The way we write also differs and needs to included in our i18n support. For example most of the languages follow a left-right direction while writing but some languages like Urdu tend to follow a right-left direction.&lt;br /&gt;
#The numbering symbols also vary from language to language. So when we display or accept any text with numbers, we must have i18n to support this mapping.&lt;br /&gt;
#The languages also differ in the use of grammar and structure of the sentences.For example the grammar rules and structure formation in English is way different than the one followed by another language like Sanskrit.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Culture and Writing Conventions:&lt;br /&gt;
&lt;br /&gt;
:Even if the language with the same characters and grammar is used, the use of the language , the symbols , the way of writing and many other things change with change in the region.&lt;br /&gt;
:Following are some of the examples:&lt;br /&gt;
&lt;br /&gt;
#There are some cultures that have some regulations about having a middle name as father’s name but other cultures don’t necessary include the middle name.&lt;br /&gt;
#There might be cases when there are different names or terminologies used in different cultures for the same purpose. For example, to identify a citizen uniquely US has the system of SSN while India is in the process of implementing this by using the term as Aadhar number.&lt;br /&gt;
#Another example of difference in the writing convention can be taken as that of a postal code. Some countries have 6 digit postal codes while others have 5.&lt;br /&gt;
#There is a difference in the use of many other things like the currency(like INR,dollars,Euro) used, the symbols(€,$,₹) used , the units in which the weights , temperature are measured. Another example could be the use of lakhs , crores for mentioning any financial figures in some countries while others use millions, billions.&lt;br /&gt;
#There could also be a difference in the formats used for a same thing. For example the format of writing dates and times vary from one region to another.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* We also have to be careful that we cover all the sensitive topics and issues particular to a language or region.&lt;br /&gt;
&lt;br /&gt;
:Similarly there are many other factors that we need to take care of when we support internationalization for a particular language in a particular region.&lt;br /&gt;
&lt;br /&gt;
= Internationalization in Rails =&lt;br /&gt;
&lt;br /&gt;
:Internationalization support was extended from Rails version 2.2. So in order to internationalize a rails application, it has to be migrated :to Rails 2.2 or above. Every static string in the Rails framework — e.g. Active Record validation messages, time and date formats — have :been internationalized.&lt;br /&gt;
&lt;br /&gt;
:Following needs to be done in order to internationalize a rails application:&lt;br /&gt;
:#Ensure support for internationalization by migrating to appropriate version of rails if needed.&lt;br /&gt;
:#Tell rails where to find the appropriate translations files&lt;br /&gt;
:#Tell rails how to switch locales&lt;br /&gt;
&lt;br /&gt;
::YAML (.yml) or plain Ruby (.rb) files are used for storing translations.&lt;br /&gt;
&lt;br /&gt;
== History ==&lt;br /&gt;
&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100pt&amp;quot;| Ruby 2.2    || Internationalization support was extended from this version of Rails.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 2.3    || Additional feature for Localized Views was added in this version. The view files were rendered with an extension of the locale name.I18n#available_locales and I18n::SimpleBackend#available_locales is available to retrieve an array of available locales.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 3.0    || Some additional features were added to the I18n gem for speed improvements like default translations for attributes,automatic pull for translations on form submit, etc.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 3.1    || I18n namespace lookup support removed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Ways to configure Internationalization in Rails ==&lt;br /&gt;
&lt;br /&gt;
:We can set up a rails application to support internationalization in a number of ways. Below are the various ways to configure our rails application for internationalization.&lt;br /&gt;
&lt;br /&gt;
#'''Configure the I18n module:'''&amp;lt;br&amp;gt;Rails adds all .rb and .yml files from the config/locales directory to your translations load path, automatically. This is the default setting provided by the [https://github.com/svenfuchs/i18n I18n gem]. In order to override this setting we have to make changes in the application.rb files that have instructions on how to add locales from another directory and how to set a different default locale.&lt;br /&gt;
#'''Custom I18n Configuration Setup:'''&amp;lt;br&amp;gt;Optionally, the above code can be placed anywhere in the application preferably in initializers.&lt;br /&gt;
#'''Setting and passing locale:'''&amp;lt;br&amp;gt;The above two steps help setup a default locale throughout the application. But in case we have to provide our application in different languages, we can setup the application default locale in the application.rb and then set the locale using the application-controller.rb before_action. We can then pass the locale we want as a query param for example http://study.com/books?locale=es&lt;br /&gt;
#'''Setting the locale from the domain name:'''&amp;lt;br&amp;gt;Similar to option 3 but instead of passing the locale as a query param, the locale is a part of the domain name itself. Example http://study.es&lt;br /&gt;
::You can implement it like this in your ApplicationController before_action&lt;br /&gt;
#'''Setting the locale from the URL params:'''&amp;lt;br&amp;gt;&lt;br /&gt;
##This can be a tedious task as we have to pass the locale on each request. &lt;br /&gt;
##Rails provides us an alternative for &amp;quot;centralizing dynamic decisions about the URLs&amp;quot; in its ApplicationController#default_url_options and helper methods are dependent on it (by implementing/overriding this method). This will now automatically include the locale param in the query string&lt;br /&gt;
##We can also set the locale in the URL route. For example -http://study.com/es/books .This is achievable by using over-riding default_url_options. You just have to set up your routes with scoping option in routes.rb. &lt;br /&gt;
#'''Setting the locale from client supplied information:'''&amp;lt;br&amp;gt;This can be done in 3 ways&lt;br /&gt;
##Using the default locale of the client browser&lt;br /&gt;
##Using client location to select the locale&lt;br /&gt;
##Saving the users choice of locale as a part of user profile&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Internationalizing Rails application ==&lt;br /&gt;
&lt;br /&gt;
:After your application is prepared for internationalization, we need to use the feature in our application. &lt;br /&gt;
:This can be done in the following ways:&lt;br /&gt;
&lt;br /&gt;
1. '''Adding Translations:'''&lt;br /&gt;
:In order to internationalize rails code, replace the strings with calls to  the ‘t’ helper.&amp;lt;br&amp;gt;For example: &lt;br /&gt;
 class HelloWorld &lt;br /&gt;
  def sayHello&lt;br /&gt;
    puts t(:hello_world)&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;%=t :hello_world %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:The helper method t also catches missing translations and displays appropriate error message.&lt;br /&gt;
 &amp;lt;nowiki /&amp;gt;# config/locales/en.yml&lt;br /&gt;
 en: hello_world: Hello world!&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki /&amp;gt;# config/locales/es.yml&lt;br /&gt;
 es: hello_world: hola mundo&lt;br /&gt;
&lt;br /&gt;
2. '''Passing variables to translation:'''&lt;br /&gt;
:You can use variables in the translation messages and pass their values from the view.&lt;br /&gt;
 en:&lt;br /&gt;
 portal: &amp;quot;Mypack&amp;quot;&lt;br /&gt;
   university:&lt;br /&gt;
    ncsu:&lt;br /&gt;
    description: ! 'NCSU student information is accessed on %{portal_name}’ &lt;br /&gt;
&lt;br /&gt;
 t('.description', portal_name: t(‘portal’))&lt;br /&gt;
&lt;br /&gt;
3. '''Adding date/ time formats:'''&lt;br /&gt;
:OK! Now let's add a timestamp to the view, so we can demo the date/time localization feature as well. To localize the time format you pass the Time object to I18n.l or (preferably) use ‘l’ helper. You can pick a format by passing the :format option — by default the :default format is used.&lt;br /&gt;
:In the view file:&lt;br /&gt;
 &amp;lt;%= l Time.now, format: :short %&amp;gt;&lt;br /&gt;
:In the yml file:&lt;br /&gt;
  es:&lt;br /&gt;
   time:&lt;br /&gt;
     formats:&lt;br /&gt;
       short: &amp;quot; Son las %H&amp;quot;&lt;br /&gt;
&lt;br /&gt;
4. '''Inflection rules for locales other than english:'''&lt;br /&gt;
:Rails 4.0 provides a feature to define inflection rules (singularization and pluralization)  in config/initializers/inflections.rb. &lt;br /&gt;
&lt;br /&gt;
5. '''Localized views:'''&lt;br /&gt;
:For static websites available in different languages or for large static content, localized views is a useful feature. This feature enables having separate view file for different locales. For example for default locale we can have show.html.erb file while for Spanish we can have show.es.html.erb. Thus we don’t need to maintain long .yml files for each supported locale for long static pages.&lt;br /&gt;
&lt;br /&gt;
== Internationalization Features ==&lt;br /&gt;
&lt;br /&gt;
1. '''Using Different Backends:'''&lt;br /&gt;
:The i18n provides a [http://www.ruby-doc.org/gems/docs/s/synergy_russian-0.2.8/I18n/Backend/Simple.html simple backend] by default. We can change the backend to an active records backend or chain multiple backends as per the requirements of our application. I18n gem also provides cache, fallback and pluralization feature for the backends.&lt;br /&gt;
&lt;br /&gt;
2. '''Pluralization:'''&lt;br /&gt;
:Different languages have different rules for pluralization. Thus, the I18n API provides a flexible pluralization feature.&lt;br /&gt;
&lt;br /&gt;
3. '''Fallbacks:'''&lt;br /&gt;
:In case translation for a certain  locale is missing we can define fallback chain for the locales.&lt;br /&gt;
:For example we can define a fallback chain of the form &lt;br /&gt;
 :'en-CA' =&amp;gt; :'en-US', :'en-US' =&amp;gt; :en, :de =&amp;gt; :en &lt;br /&gt;
&lt;br /&gt;
:if the translation for en-CA is missing rails looks for en-US , if en-US is missing it then looks for en and so on.&lt;br /&gt;
&lt;br /&gt;
4. '''Cascading lookups:'''&lt;br /&gt;
:If a given key is not found, it is broken and a lookup is performed for the remaining portion of the key before finally falling back to the defaults.&lt;br /&gt;
&lt;br /&gt;
5. '''Translation symlinks:'''&lt;br /&gt;
:A key can be a value for another key.&lt;br /&gt;
:Example:&lt;br /&gt;
 person: ‘ash’&lt;br /&gt;
 student: :person&lt;br /&gt;
 employee: :person&lt;br /&gt;
&lt;br /&gt;
:Ash can be an employee or a student. Each key represents the same value.&lt;br /&gt;
&lt;br /&gt;
6. '''Translation procs:'''&lt;br /&gt;
:I18n gem allows writing translation logic in the translation lookup process.&lt;br /&gt;
:For example:&lt;br /&gt;
 :en&lt;br /&gt;
  	:addressing =&amp;gt; lambda { |values|&lt;br /&gt;
 		person=values[:person]&lt;br /&gt;
 		address=person.male? ?  “Sir” : “Madam”&lt;br /&gt;
 	“Hello, #{person.address}”&lt;br /&gt;
 &lt;br /&gt;
 t(:addressing , :person =&amp;gt; mary)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
http://guides.rubyonrails.org/3_0_release_notes.html &amp;lt;br&amp;gt;&lt;br /&gt;
http://rubylearning.com/blog/2012/07/24/minimal-i18n-with-rails-3-2/ &amp;lt;br&amp;gt;&lt;br /&gt;
http://blog.lingohub.com/developers/2013/08/internationalization-for-ruby-i18n-gem/ &amp;lt;br&amp;gt;&lt;br /&gt;
http://vimeo.com/12665914 &amp;lt;br&amp;gt;&lt;br /&gt;
http://www.artweb-design.de/2009/7/19/experimental-extensions-in-i18n-pluralization-fallbacks-gettext-cache-and-chain &amp;lt;br&amp;gt;&lt;br /&gt;
http://asciicasts.com/episodes/256-i18n-backends &amp;lt;br&amp;gt;&lt;br /&gt;
http://blog.lingohub.com/developers/2013/08/i18n-gem-advanced-features-ruby-rails-internationalization/ &amp;lt;br&amp;gt;&lt;br /&gt;
http://en.wikipedia.org/wiki/Internationalization_and_localization &amp;lt;br&amp;gt;&lt;br /&gt;
http://www.ruby-doc.org/gems/docs/s/synergy_russian-0.2.8/I18n/Backend/Simple.html &amp;lt;br&amp;gt;&lt;br /&gt;
https://github.com/svenfuchs/i18n &amp;lt;br&amp;gt;&lt;br /&gt;
http://guides.rubyonrails.org/v2.3.11/i18n.html &amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Srparadk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w18_bs&amp;diff=76128</id>
		<title>CSC/ECE 517 Fall 2013/ch1 1w18 bs</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w18_bs&amp;diff=76128"/>
		<updated>2013-09-16T21:12:03Z</updated>

		<summary type="html">&lt;p&gt;Srparadk: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Internationalization in Rails&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
:In general when we start a conversation, the first default language of communication we use is English, but if the other person is not familiar with English we try and translate our dialogue in a language that the person is familiar with. Similarly whenever we write a program or a document we write it in English by default. But what if someone who is not familiar with English wants to read your program or code? The simple solution is that we translate program or code into a language that the person is familiar with. And for this, we use a term called internationalization.&lt;br /&gt;
&lt;br /&gt;
:Internationalization is a way by which we can view an application in various languages without actually making changes to the code of the application. This saves us a lot of time and effort, as we don’t have to write or edit the same code or document in all the copies.&lt;br /&gt;
&lt;br /&gt;
:Internationalization has an acronym, rather more of a numeronym ,which is i18n where the number 18 represents the number of letters between the first and last letters in the word internationalization.&lt;br /&gt;
&lt;br /&gt;
== Aspects to consider in Internationalization ==&lt;br /&gt;
&lt;br /&gt;
:Now when we are to change our application according to a particular language or a region , we need to keep in mind numerous points that are important, implicit, particular or sensitive to that language or region. Like for example when we take a language into consideration for which our application needs to be translated, we need to consider the spoken and written aspects of that language. Also, there might be a case when we have the same language but it differs from one region to other. For this we need to keep in mind the typical change in the use of words, grammar and symbol for each region that uses the same language. Our application must also provide support for the varied writing conventions that differ from a language to another language or from one region to another.&lt;br /&gt;
&lt;br /&gt;
:Below are the examples of the points we need to keep in mind while we provide internationalization to our application :&lt;br /&gt;
&lt;br /&gt;
* Language :&lt;br /&gt;
&lt;br /&gt;
:Here the i18n support to an application needs to provide the character encoding keeping in mind the following points:&lt;br /&gt;
&lt;br /&gt;
#The written language differs. For example most of the languages like English, French, German follow a script that can have inputs from a standard keyboard. But there are other languages like Hindi, Marathi, Sanskrit that follow a script called Devnagri and this cannot be directly typed in from a standard keyboard. So if we have to provide support for these languages we need to support the translation of the characters used in these scripts.&lt;br /&gt;
#The way we write also differs and needs to included in our i18n support. For example most of the languages follow a left-right direction while writing but some languages like Urdu tend to follow a right-left direction.&lt;br /&gt;
#The numbering symbols also vary from language to language. So when we display or accept any text with numbers, we must have i18n to support this mapping.&lt;br /&gt;
#The languages also differ in the use of grammar and structure of the sentences.For example the grammar rules and structure formation in English is way different than the one followed by another language like Sanskrit.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Culture and Writing Conventions:&lt;br /&gt;
&lt;br /&gt;
:Even if the language with the same characters and grammar is used, the use of the language , the symbols , the way of writing and many other things change with change in the region.&lt;br /&gt;
:Following are some of the examples:&lt;br /&gt;
&lt;br /&gt;
#There are some cultures that have some regulations about having a middle name as father’s name but other cultures don’t necessary include the middle name.&lt;br /&gt;
#There might be cases when there are different names or terminologies used in different cultures for the same purpose. For example, to identify a citizen uniquely US has the system of SSN while India is in the process of implementing this by using the term as Aadhar number.&lt;br /&gt;
#Another example of difference in the writing convention can be taken as that of a postal code. Some countries have 6 digit postal codes while others have 5.&lt;br /&gt;
#There is a difference in the use of many other things like the currency(like INR,dollars,Euro) used, the symbols(€,$,₹) used , the units in which the weights , temperature are measured. Another example could be the use of lakhs , crores for mentioning any financial figures in some countries while others use millions, billions.&lt;br /&gt;
#There could also be a difference in the formats used for a same thing. For example the format of writing dates and times vary from one region to another.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* We also have to be careful that we cover all the sensitive topics and issues particular to a language or region.&lt;br /&gt;
&lt;br /&gt;
:Similarly there are many other factors that we need to take care of when we support internationalization for a particular language in a particular region.&lt;br /&gt;
&lt;br /&gt;
= Internationalization in Rails =&lt;br /&gt;
&lt;br /&gt;
:Internationalization support was extended from Rails version 2.2. So in order to internationalize a rails application, it has to be migrated :to Rails 2.2 or above. Every static string in the Rails framework — e.g. Active Record validation messages, time and date formats — have :been internationalized.&lt;br /&gt;
&lt;br /&gt;
:Following needs to be done in order to internationalize a rails application:&lt;br /&gt;
:#Ensure support for internationalization by migrating to appropriate version of rails if needed.&lt;br /&gt;
:#Tell rails where to find the appropriate translations files&lt;br /&gt;
:#Tell rails how to switch locales&lt;br /&gt;
&lt;br /&gt;
::YAML (.yml) or plain Ruby (.rb) files are used for storing translations.&lt;br /&gt;
&lt;br /&gt;
== History ==&lt;br /&gt;
&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100pt&amp;quot;| Ruby 2.2    || Internationalization support was extended from this version of Rails.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 2.3    || Additional feature for Localized Views was added in this version. The view files were rendered with an extension of the locale name.I18n#available_locales and I18n::SimpleBackend#available_locales is available to retrieve an array of available locales.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 3.0    || Some additional features were added to the I18n gem for speed improvements like default translations for attributes,automatic pull for translations on form submit, etc.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 3.1    || I18n namespace lookup support removed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Ways to configure Internationalization in Rails ==&lt;br /&gt;
&lt;br /&gt;
:We can set up a rails application to support internationalization in a number of ways. Below are the various ways to configure our rails application for internationalization.&lt;br /&gt;
&lt;br /&gt;
#'''Configure the I18n module:'''&amp;lt;br&amp;gt;Rails adds all .rb and .yml files from the config/locales directory to your translations load path, automatically. This is the default setting provided by the [https://github.com/svenfuchs/i18n I18n gem]. In order to override this setting we have to make changes in the application.rb files that have instructions on how to add locales from another directory and how to set a different default locale.&lt;br /&gt;
#'''Custom I18n Configuration Setup:'''&amp;lt;br&amp;gt;Optionally, the above code can be placed anywhere in the application preferably in initializers.&lt;br /&gt;
#'''Setting and passing locale:'''&amp;lt;br&amp;gt;The above two steps help setup a default locale throughout the application. But in case we have to provide our application in different languages, we can setup the application default locale in the application.rb and then set the locale using the application-controller.rb before_action. We can then pass the locale we want as a query param for example http://study.com/books?locale=es&lt;br /&gt;
#'''Setting the locale from the domain name:'''&amp;lt;br&amp;gt;Similar to option 3 but instead of passing the locale as a query param, the locale is a part of the domain name itself. Example http://study.es&lt;br /&gt;
::You can implement it like this in your ApplicationController before_action&lt;br /&gt;
#'''Setting the locale from the URL params:'''&amp;lt;br&amp;gt;&lt;br /&gt;
##This can be a tedious task as we have to pass the locale on each request. &lt;br /&gt;
##Rails provides us an alternative for &amp;quot;centralizing dynamic decisions about the URLs&amp;quot; in its ApplicationController#default_url_options and helper methods are dependent on it (by implementing/overriding this method). This will now automatically include the locale param in the query string&lt;br /&gt;
##We can also set the locale in the URL route. For example -http://study.com/es/books .This is achievable by using over-riding default_url_options. You just have to set up your routes with scoping option in routes.rb. &lt;br /&gt;
#'''Setting the locale from client supplied information:'''&amp;lt;br&amp;gt;This can be done in 3 ways&lt;br /&gt;
##Using the default locale of the client browser&lt;br /&gt;
##Using client location to select the locale&lt;br /&gt;
##Saving the users choice of locale as a part of user profile&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Internationalizing Rails application ==&lt;br /&gt;
&lt;br /&gt;
:After your application is prepared for internationalization, we need to use the feature in our application. &lt;br /&gt;
:This can be done in the following ways:&lt;br /&gt;
&lt;br /&gt;
1. '''Adding Translations:'''&lt;br /&gt;
:In order to internationalize rails code, replace the strings with calls to  the ‘t’ helper.&amp;lt;br&amp;gt;For example: &lt;br /&gt;
 class HelloWorld &lt;br /&gt;
  def sayHello&lt;br /&gt;
    puts t(:hello_world)&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;%=t :hello_world %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:The helper method t also catches missing translations and displays appropriate error message.&lt;br /&gt;
 &amp;lt;nowiki /&amp;gt;# config/locales/en.yml&lt;br /&gt;
 en: hello_world: Hello world!&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki /&amp;gt;# config/locales/es.yml&lt;br /&gt;
 es: hello_world: hola mundo&lt;br /&gt;
&lt;br /&gt;
2. '''Passing variables to translation:'''&lt;br /&gt;
:You can use variables in the translation messages and pass their values from the view.&lt;br /&gt;
 en:&lt;br /&gt;
 portal: &amp;quot;Mypack&amp;quot;&lt;br /&gt;
   university:&lt;br /&gt;
    ncsu:&lt;br /&gt;
    description: ! 'NCSU student information is accessed on %{portal_name}’ &lt;br /&gt;
&lt;br /&gt;
 t('.description', portal_name: t(‘portal’))&lt;br /&gt;
&lt;br /&gt;
3. '''Adding date/ time formats:'''&lt;br /&gt;
:OK! Now let's add a timestamp to the view, so we can demo the date/time localization feature as well. To localize the time format you pass the Time object to I18n.l or (preferably) use ‘l’ helper. You can pick a format by passing the :format option — by default the :default format is used.&lt;br /&gt;
:In the view file:&lt;br /&gt;
 &amp;lt;%= l Time.now, format: :short %&amp;gt;&lt;br /&gt;
:In the yml file:&lt;br /&gt;
  es:&lt;br /&gt;
   time:&lt;br /&gt;
     formats:&lt;br /&gt;
       short: &amp;quot; Son las %H&amp;quot;&lt;br /&gt;
&lt;br /&gt;
4. '''Inflection rules for locales other than english:'''&lt;br /&gt;
:Rails 4.0 provides a feature to define inflection rules (singularization and pluralization)  in config/initializers/inflections.rb. &lt;br /&gt;
&lt;br /&gt;
5. '''Localized views:'''&lt;br /&gt;
:For static websites available in different languages or for large static content, localized views is a useful feature. This feature enables having separate view file for different locales. For example for default locale we can have show.html.erb file while for Spanish we can have show.es.html.erb. Thus we don’t need to maintain long .yml files for each supported locale for long static pages.&lt;br /&gt;
&lt;br /&gt;
== Internationalization Features ==&lt;br /&gt;
&lt;br /&gt;
1. '''Using Different Backends:'''&lt;br /&gt;
:The i18n provides a [http://www.ruby-doc.org/gems/docs/s/synergy_russian-0.2.8/I18n/Backend/Simple.html simple backend] by default. We can change the backend to an active records backend or chain multiple backends as per the requirements of our application. I18n gem also provides cache, fallback and pluralization feature for the backends.&lt;br /&gt;
&lt;br /&gt;
2. '''Pluralization:'''&lt;br /&gt;
:Different languages have different rules for pluralization. Thus, the I18n API provides a flexible pluralization feature.&lt;br /&gt;
&lt;br /&gt;
3. '''Fallbacks:'''&lt;br /&gt;
:In case translation for a certain  locale is missing we can define fallback chain for the locales.&lt;br /&gt;
:For example we can define a fallback chain of the form &lt;br /&gt;
 :'en-CA' =&amp;gt; :'en-US', :'en-US' =&amp;gt; :en, :de =&amp;gt; :en &lt;br /&gt;
&lt;br /&gt;
:if the translation for en-CA is missing rails looks for en-US , if en-US is missing it then looks for en and so on.&lt;br /&gt;
&lt;br /&gt;
4. '''Cascading lookups:'''&lt;br /&gt;
:If a given key is not found, it is broken and a lookup is performed for the remaining portion of the key before finally falling back to the defaults.&lt;br /&gt;
&lt;br /&gt;
5. '''Translation symlinks:'''&lt;br /&gt;
:A key can be a value for another key.&lt;br /&gt;
:Example:&lt;br /&gt;
 person: ‘ash’&lt;br /&gt;
 student: :person&lt;br /&gt;
 employee: :person&lt;br /&gt;
&lt;br /&gt;
:Ash can be an employee or a student. Each key represents the same value.&lt;br /&gt;
&lt;br /&gt;
6. '''Translation procs:'''&lt;br /&gt;
:I18n gem allows writing translation logic in the translation lookup process.&lt;br /&gt;
:For example:&lt;br /&gt;
 :en&lt;br /&gt;
  	:addressing =&amp;gt; lambda { |values|&lt;br /&gt;
 		person=values[:person]&lt;br /&gt;
 		address=person.male? ?  “Sir” : “Madam”&lt;br /&gt;
 	“Hello, #{person.address}”&lt;br /&gt;
 &lt;br /&gt;
 t(:addressing , :person =&amp;gt; mary)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
http://guides.rubyonrails.org/3_0_release_notes.html &amp;lt;br&amp;gt;&lt;br /&gt;
http://rubylearning.com/blog/2012/07/24/minimal-i18n-with-rails-3-2/ &amp;lt;br&amp;gt;&lt;br /&gt;
http://blog.lingohub.com/developers/2013/08/internationalization-for-ruby-i18n-gem/ &amp;lt;br&amp;gt;&lt;br /&gt;
http://vimeo.com/12665914 &amp;lt;br&amp;gt;&lt;br /&gt;
http://www.artweb-design.de/2009/7/19/experimental-extensions-in-i18n-pluralization-fallbacks-gettext-cache-and-chain &amp;lt;br&amp;gt;&lt;br /&gt;
http://asciicasts.com/episodes/256-i18n-backends &amp;lt;br&amp;gt;&lt;br /&gt;
http://blog.lingohub.com/developers/2013/08/i18n-gem-advanced-features-ruby-rails-internationalization/ &amp;lt;br&amp;gt;&lt;br /&gt;
http://en.wikipedia.org/wiki/Internationalization_and_localization &amp;lt;br&amp;gt;&lt;br /&gt;
http://www.ruby-doc.org/gems/docs/s/synergy_russian-0.2.8/I18n/Backend/Simple.html &amp;lt;br&amp;gt;&lt;br /&gt;
https://github.com/svenfuchs/i18n &amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Srparadk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w18_bs&amp;diff=76127</id>
		<title>CSC/ECE 517 Fall 2013/ch1 1w18 bs</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w18_bs&amp;diff=76127"/>
		<updated>2013-09-16T21:11:10Z</updated>

		<summary type="html">&lt;p&gt;Srparadk: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Internationalization in Rails&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
:In general when we start a conversation, the first default language of communication we use is English, but if the other person is not familiar with English we try and translate our dialogue in a language that the person is familiar with. Similarly whenever we write a program or a document we write it in English by default. But what if someone who is not familiar with English wants to read your program or code? The simple solution is that we translate program or code into a language that the person is familiar with. And for this, we use a term called internationalization.&lt;br /&gt;
&lt;br /&gt;
:Internationalization is a way by which we can view an application in various languages without actually making changes to the code of the application. This saves us a lot of time and effort, as we don’t have to write or edit the same code or document in all the copies.&lt;br /&gt;
&lt;br /&gt;
:Internationalization has an acronym, rather more of a numeronym ,which is i18n where the number 18 represents the number of letters between the first and last letters in the word internationalization.&lt;br /&gt;
&lt;br /&gt;
== Aspects to consider in Internationalization ==&lt;br /&gt;
&lt;br /&gt;
:Now when we are to change our application according to a particular language or a region , we need to keep in mind numerous points that are important, implicit, particular or sensitive to that language or region. Like for example when we take a language into consideration for which our application needs to be translated, we need to consider the spoken and written aspects of that language. Also, there might be a case when we have the same language but it differs from one region to other. For this we need to keep in mind the typical change in the use of words, grammar and symbol for each region that uses the same language. Our application must also provide support for the varied writing conventions that differ from a language to another language or from one region to another.&lt;br /&gt;
&lt;br /&gt;
:Below are the examples of the points we need to keep in mind while we provide internationalization to our application :&lt;br /&gt;
&lt;br /&gt;
* Language :&lt;br /&gt;
&lt;br /&gt;
:Here the i18n support to an application needs to provide the character encoding keeping in mind the following points:&lt;br /&gt;
&lt;br /&gt;
#The written language differs. For example most of the languages like English, French, German follow a script that can have inputs from a standard keyboard. But there are other languages like Hindi, Marathi, Sanskrit that follow a script called Devnagri and this cannot be directly typed in from a standard keyboard. So if we have to provide support for these languages we need to support the translation of the characters used in these scripts.&lt;br /&gt;
#The way we write also differs and needs to included in our i18n support. For example most of the languages follow a left-right direction while writing but some languages like Urdu tend to follow a right-left direction.&lt;br /&gt;
#The numbering symbols also vary from language to language. So when we display or accept any text with numbers, we must have i18n to support this mapping.&lt;br /&gt;
#The languages also differ in the use of grammar and structure of the sentences.For example the grammar rules and structure formation in English is way different than the one followed by another language like Sanskrit.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Culture and Writing Conventions:&lt;br /&gt;
&lt;br /&gt;
:Even if the language with the same characters and grammar is used, the use of the language , the symbols , the way of writing and many other things change with change in the region.&lt;br /&gt;
:Following are some of the examples:&lt;br /&gt;
&lt;br /&gt;
#There are some cultures that have some regulations about having a middle name as father’s name but other cultures don’t necessary include the middle name.&lt;br /&gt;
#There might be cases when there are different names or terminologies used in different cultures for the same purpose. For example, to identify a citizen uniquely US has the system of SSN while India is in the process of implementing this by using the term as Aadhar number.&lt;br /&gt;
#Another example of difference in the writing convention can be taken as that of a postal code. Some countries have 6 digit postal codes while others have 5.&lt;br /&gt;
#There is a difference in the use of many other things like the currency(like INR,dollars,Euro) used, the symbols(€,$,₹) used , the units in which the weights , temperature are measured. Another example could be the use of lakhs , crores for mentioning any financial figures in some countries while others use millions, billions.&lt;br /&gt;
#There could also be a difference in the formats used for a same thing. For example the format of writing dates and times vary from one region to another.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* We also have to be careful that we cover all the sensitive topics and issues particular to a language or region.&lt;br /&gt;
&lt;br /&gt;
:Similarly there are many other factors that we need to take care of when we support internationalization for a particular language in a particular region.&lt;br /&gt;
&lt;br /&gt;
= Internationalization in Rails =&lt;br /&gt;
&lt;br /&gt;
:Internationalization support was extended from Rails version 2.2. So in order to internationalize a rails application, it has to be migrated :to Rails 2.2 or above. Every static string in the Rails framework — e.g. Active Record validation messages, time and date formats — have :been internationalized.&lt;br /&gt;
&lt;br /&gt;
:Following needs to be done in order to internationalize a rails application:&lt;br /&gt;
:#Ensure support for internationalization by migrating to appropriate version of rails if needed.&lt;br /&gt;
:#Tell rails where to find the appropriate translations files&lt;br /&gt;
:#Tell rails how to switch locales&lt;br /&gt;
&lt;br /&gt;
::YAML (.yml) or plain Ruby (.rb) files are used for storing translations.&lt;br /&gt;
&lt;br /&gt;
== History ==&lt;br /&gt;
&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100pt&amp;quot;| Ruby 2.2    || Internationalization support was extended from this version of Rails.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 2.3    || Additional feature for Localized Views was added in this version. The view files were rendered with an extension of the locale name.I18n#available_locales and I18n::SimpleBackend#available_locales is available to retrieve an array of available locales.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 3.0    || Some additional features were added to the I18n gem for speed improvements like default translations for attributes,automatic pull for translations on form submit, etc.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 3.1    || I18n namespace lookup support removed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Ways to configure Internationalization in Rails ==&lt;br /&gt;
&lt;br /&gt;
:We can set up a rails application to support internationalization in a number of ways. Below are the various ways to configure our rails application for internationalization.&lt;br /&gt;
&lt;br /&gt;
#'''Configure the I18n module:'''&amp;lt;br&amp;gt;Rails adds all .rb and .yml files from the config/locales directory to your translations load path, automatically. This is the default setting provided by the [https://github.com/svenfuchs/i18n I18n gem]. In order to override this setting we have to make changes in the application.rb files that have instructions on how to add locales from another directory and how to set a different default locale.&lt;br /&gt;
#'''Custom I18n Configuration Setup:'''&amp;lt;br&amp;gt;Optionally, the above code can be placed anywhere in the application preferably in initializers.&lt;br /&gt;
#'''Setting and passing locale:'''&amp;lt;br&amp;gt;The above two steps help setup a default locale throughout the application. But in case we have to provide our application in different languages, we can setup the application default locale in the application.rb and then set the locale using the application-controller.rb before_action. We can then pass the locale we want as a query param for example http://study.com/books?locale=es&lt;br /&gt;
#'''Setting the locale from the domain name:'''&amp;lt;br&amp;gt;Similar to option 3 but instead of passing the locale as a query param, the locale is a part of the domain name itself. Example http://study.es&lt;br /&gt;
::You can implement it like this in your ApplicationController before_action&lt;br /&gt;
#'''Setting the locale from the URL params:'''&amp;lt;br&amp;gt;&lt;br /&gt;
##This can be a tedious task as we have to pass the locale on each request. &lt;br /&gt;
##Rails provides us an alternative for &amp;quot;centralizing dynamic decisions about the URLs&amp;quot; in its ApplicationController#default_url_options and helper methods are dependent on it (by implementing/overriding this method). This will now automatically include the locale param in the query string&lt;br /&gt;
##We can also set the locale in the URL route. For example -http://study.com/es/books .This is achievable by using over-riding default_url_options. You just have to set up your routes with scoping option in routes.rb. &lt;br /&gt;
#'''Setting the locale from client supplied information:'''&amp;lt;br&amp;gt;This can be done in 3 ways&lt;br /&gt;
##Using the default locale of the client browser&lt;br /&gt;
##Using client location to select the locale&lt;br /&gt;
##Saving the users choice of locale as a part of user profile&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Internationalizing Rails application ==&lt;br /&gt;
&lt;br /&gt;
:After your application is prepared for internationalization, we need to use the feature in our application. &lt;br /&gt;
:This can be done in the following ways:&lt;br /&gt;
&lt;br /&gt;
1. '''Adding Translations:'''&lt;br /&gt;
:In order to internationalize rails code, replace the strings with calls to  the ‘t’ helper.&amp;lt;br&amp;gt;For example: &lt;br /&gt;
 class HelloWorld &lt;br /&gt;
  def sayHello&lt;br /&gt;
    puts t(:hello_world)&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;%=t :hello_world %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:The helper method t also catches missing translations and displays appropriate error message.&lt;br /&gt;
 &amp;lt;nowiki /&amp;gt;# config/locales/en.yml&lt;br /&gt;
 en: hello_world: Hello world!&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki /&amp;gt;# config/locales/es.yml&lt;br /&gt;
 es: hello_world: hola mundo&lt;br /&gt;
&lt;br /&gt;
2. '''Passing variables to translation:'''&lt;br /&gt;
:You can use variables in the translation messages and pass their values from the view.&lt;br /&gt;
 en:&lt;br /&gt;
 portal: &amp;quot;Mypack&amp;quot;&lt;br /&gt;
   university:&lt;br /&gt;
    ncsu:&lt;br /&gt;
    description: ! 'NCSU student information is accessed on %{portal_name}’ &lt;br /&gt;
&lt;br /&gt;
 t('.description', portal_name: t(‘portal’))&lt;br /&gt;
&lt;br /&gt;
3. '''Adding date/ time formats:'''&lt;br /&gt;
:OK! Now let's add a timestamp to the view, so we can demo the date/time localization feature as well. To localize the time format you pass the Time object to I18n.l or (preferably) use ‘l’ helper. You can pick a format by passing the :format option — by default the :default format is used.&lt;br /&gt;
:In the view file:&lt;br /&gt;
 &amp;lt;%= l Time.now, format: :short %&amp;gt;&lt;br /&gt;
:In the yml file:&lt;br /&gt;
  es:&lt;br /&gt;
   time:&lt;br /&gt;
     formats:&lt;br /&gt;
       short: &amp;quot; Son las %H&amp;quot;&lt;br /&gt;
&lt;br /&gt;
4. '''Inflection rules for locales other than english:'''&lt;br /&gt;
:Rails 4.0 provides a feature to define inflection rules (singularization and pluralization)  in config/initializers/inflections.rb. &lt;br /&gt;
&lt;br /&gt;
5. '''Localized views:'''&lt;br /&gt;
:For static websites available in different languages or for large static content, localized views is a useful feature. This feature enables having separate view file for different locales. For example for default locale we can have show.html.erb file while for Spanish we can have show.es.html.erb. Thus we don’t need to maintain long .yml files for each supported locale for long static pages.&lt;br /&gt;
&lt;br /&gt;
== Internationalization Features ==&lt;br /&gt;
&lt;br /&gt;
1. '''Using Different Backends:'''&lt;br /&gt;
:The i18n provides a [http://www.ruby-doc.org/gems/docs/s/synergy_russian-0.2.8/I18n/Backend/Simple.html simple backend] by default. We can change the backend to an active records backend or chain multiple backends as per the requirements of our application. I18n gem also provides cache, fallback and pluralization feature for the backends.&lt;br /&gt;
&lt;br /&gt;
2. '''Pluralization:'''&lt;br /&gt;
:Different languages have different rules for pluralization. Thus, the I18n API provides a flexible pluralization feature.&lt;br /&gt;
&lt;br /&gt;
3. '''Fallbacks:'''&lt;br /&gt;
:In case translation for a certain  locale is missing we can define fallback chain for the locales.&lt;br /&gt;
:For example we can define a fallback chain of the form &lt;br /&gt;
 :'en-CA' =&amp;gt; :'en-US', :'en-US' =&amp;gt; :en, :de =&amp;gt; :en &lt;br /&gt;
&lt;br /&gt;
:if the translation for en-CA is missing rails looks for en-US , if en-US is missing it then looks for en and so on.&lt;br /&gt;
&lt;br /&gt;
4. '''Cascading lookups:'''&lt;br /&gt;
:If a given key is not found, it is broken and a lookup is performed for the remaining portion of the key before finally falling back to the defaults.&lt;br /&gt;
&lt;br /&gt;
5. '''Translation symlinks:'''&lt;br /&gt;
:A key can be a value for another key.&lt;br /&gt;
:Example:&lt;br /&gt;
 person: ‘ash’&lt;br /&gt;
 student: :person&lt;br /&gt;
 employee: :person&lt;br /&gt;
&lt;br /&gt;
:Ash can be an employee or a student. Each key represents the same value.&lt;br /&gt;
&lt;br /&gt;
6. '''Translation procs:'''&lt;br /&gt;
:I18n gem allows writing translation logic in the translation lookup process.&lt;br /&gt;
:For example:&lt;br /&gt;
 :en&lt;br /&gt;
  	:addressing =&amp;gt; lambda { |values|&lt;br /&gt;
 		person=values[:person]&lt;br /&gt;
 		address=person.male? ?  “Sir” : “Madam”&lt;br /&gt;
 	“Hello, #{person.address}”&lt;br /&gt;
 &lt;br /&gt;
 t(:addressing , :person =&amp;gt; mary)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
http://guides.rubyonrails.org/3_0_release_notes.html&lt;br /&gt;
http://rubylearning.com/blog/2012/07/24/minimal-i18n-with-rails-3-2/&lt;br /&gt;
http://blog.lingohub.com/developers/2013/08/internationalization-for-ruby-i18n-gem/&lt;br /&gt;
http://vimeo.com/12665914&lt;br /&gt;
http://www.artweb-design.de/2009/7/19/experimental-extensions-in-i18n-pluralization-fallbacks-gettext-cache-and-chain&lt;br /&gt;
http://asciicasts.com/episodes/256-i18n-backends&lt;br /&gt;
http://blog.lingohub.com/developers/2013/08/i18n-gem-advanced-features-ruby-rails-internationalization/&lt;br /&gt;
http://en.wikipedia.org/wiki/Internationalization_and_localization &lt;br /&gt;
http://www.ruby-doc.org/gems/docs/s/synergy_russian-0.2.8/I18n/Backend/Simple.html&lt;br /&gt;
https://github.com/svenfuchs/i18n&lt;/div&gt;</summary>
		<author><name>Srparadk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w18_bs&amp;diff=76126</id>
		<title>CSC/ECE 517 Fall 2013/ch1 1w18 bs</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w18_bs&amp;diff=76126"/>
		<updated>2013-09-16T21:08:15Z</updated>

		<summary type="html">&lt;p&gt;Srparadk: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Internationalization in Rails&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
:In general when we start a conversation, the first default language of communication we use is English, but if the other person is not familiar with English we try and translate our dialogue in a language that the person is familiar with. Similarly whenever we write a program or a document we write it in English by default. But what if someone who is not familiar with English wants to read your program or code? The simple solution is that we translate program or code into a language that the person is familiar with. And for this, we use a term called internationalization.&lt;br /&gt;
&lt;br /&gt;
:Internationalization is a way by which we can view an application in various languages without actually making changes to the code of the application. This saves us a lot of time and effort, as we don’t have to write or edit the same code or document in all the copies.&lt;br /&gt;
&lt;br /&gt;
:Internationalization has an acronym, rather more of a numeronym ,which is i18n where the number 18 represents the number of letters between the first and last letters in the word internationalization.&lt;br /&gt;
&lt;br /&gt;
== Aspects to consider in Internationalization ==&lt;br /&gt;
&lt;br /&gt;
:Now when we are to change our application according to a particular language or a region , we need to keep in mind numerous points that are important, implicit, particular or sensitive to that language or region. Like for example when we take a language into consideration for which our application needs to be translated, we need to consider the spoken and written aspects of that language. Also, there might be a case when we have the same language but it differs from one region to other. For this we need to keep in mind the typical change in the use of words, grammar and symbol for each region that uses the same language. Our application must also provide support for the varied writing conventions that differ from a language to another language or from one region to another.&lt;br /&gt;
&lt;br /&gt;
:Below are the examples of the points we need to keep in mind while we provide internationalization to our application :&lt;br /&gt;
&lt;br /&gt;
* Language :&lt;br /&gt;
&lt;br /&gt;
:Here the i18n support to an application needs to provide the character encoding keeping in mind the following points:&lt;br /&gt;
&lt;br /&gt;
#The written language differs. For example most of the languages like English, French, German follow a script that can have inputs from a standard keyboard. But there are other languages like Hindi, Marathi, Sanskrit that follow a script called Devnagri and this cannot be directly typed in from a standard keyboard. So if we have to provide support for these languages we need to support the translation of the characters used in these scripts.&lt;br /&gt;
#The way we write also differs and needs to included in our i18n support. For example most of the languages follow a left-right direction while writing but some languages like Urdu tend to follow a right-left direction.&lt;br /&gt;
#The numbering symbols also vary from language to language. So when we display or accept any text with numbers, we must have i18n to support this mapping.&lt;br /&gt;
#The languages also differ in the use of grammar and structure of the sentences.For example the grammar rules and structure formation in English is way different than the one followed by another language like Sanskrit.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Culture and Writing Conventions:&lt;br /&gt;
&lt;br /&gt;
:Even if the language with the same characters and grammar is used, the use of the language , the symbols , the way of writing and many other things change with change in the region.&lt;br /&gt;
:Following are some of the examples:&lt;br /&gt;
&lt;br /&gt;
#There are some cultures that have some regulations about having a middle name as father’s name but other cultures don’t necessary include the middle name.&lt;br /&gt;
#There might be cases when there are different names or terminologies used in different cultures for the same purpose. For example, to identify a citizen uniquely US has the system of SSN while India is in the process of implementing this by using the term as Aadhar number.&lt;br /&gt;
#Another example of difference in the writing convention can be taken as that of a postal code. Some countries have 6 digit postal codes while others have 5.&lt;br /&gt;
#There is a difference in the use of many other things like the currency(like INR,dollars,Euro) used, the symbols(€,$,₹) used , the units in which the weights , temperature are measured. Another example could be the use of lakhs , crores for mentioning any financial figures in some countries while others use millions, billions.&lt;br /&gt;
#There could also be a difference in the formats used for a same thing. For example the format of writing dates and times vary from one region to another.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* We also have to be careful that we cover all the sensitive topics and issues particular to a language or region.&lt;br /&gt;
&lt;br /&gt;
:Similarly there are many other factors that we need to take care of when we support internationalization for a particular language in a particular region.&lt;br /&gt;
&lt;br /&gt;
= Internationalization in Rails =&lt;br /&gt;
&lt;br /&gt;
:Internationalization support was extended from Rails version 2.2. So in order to internationalize a rails application, it has to be migrated :to Rails 2.2 or above. Every static string in the Rails framework — e.g. Active Record validation messages, time and date formats — have :been internationalized.&lt;br /&gt;
&lt;br /&gt;
:Following needs to be done in order to internationalize a rails application:&lt;br /&gt;
:#Ensure support for internationalization by migrating to appropriate version of rails if needed.&lt;br /&gt;
:#Tell rails where to find the appropriate translations files&lt;br /&gt;
:#Tell rails how to switch locales&lt;br /&gt;
&lt;br /&gt;
::YAML (.yml) or plain Ruby (.rb) files are used for storing translations.&lt;br /&gt;
&lt;br /&gt;
== History ==&lt;br /&gt;
&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100pt&amp;quot;| Ruby 2.2    || Internationalization support was extended from this version of Rails.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 2.3    || Additional feature for Localized Views was added in this version. The view files were rendered with an extension of the locale name.I18n#available_locales and I18n::SimpleBackend#available_locales is available to retrieve an array of available locales.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 3.0    || Some additional features were added to the I18n gem for speed improvements like default translations for attributes,automatic pull for translations on form submit, etc.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 3.1    || I18n namespace lookup support removed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Ways to configure Internationalization in Rails ==&lt;br /&gt;
&lt;br /&gt;
:We can set up a rails application to support internationalization in a number of ways. Below are the various ways to configure our rails application for internationalization.&lt;br /&gt;
&lt;br /&gt;
#'''Configure the I18n module:'''&amp;lt;br&amp;gt;Rails adds all .rb and .yml files from the config/locales directory to your translations load path, automatically. This is the default setting provided by the [https://github.com/svenfuchs/i18n I18n gem]. In order to override this setting we have to make changes in the application.rb files that have instructions on how to add locales from another directory and how to set a different default locale.&lt;br /&gt;
#'''Custom I18n Configuration Setup:'''&amp;lt;br&amp;gt;Optionally, the above code can be placed anywhere in the application preferably in initializers.&lt;br /&gt;
#'''Setting and passing locale:'''&amp;lt;br&amp;gt;The above two steps help setup a default locale throughout the application. But in case we have to provide our application in different languages, we can setup the application default locale in the application.rb and then set the locale using the application-controller.rb before_action. We can then pass the locale we want as a query param for example http://study.com/books?locale=es&lt;br /&gt;
#'''Setting the locale from the domain name:'''&amp;lt;br&amp;gt;Similar to option 3 but instead of passing the locale as a query param, the locale is a part of the domain name itself. Example http://study.es&lt;br /&gt;
::You can implement it like this in your ApplicationController before_action&lt;br /&gt;
#'''Setting the locale from the URL params:'''&amp;lt;br&amp;gt;&lt;br /&gt;
##This can be a tedious task as we have to pass the locale on each request. &lt;br /&gt;
##Rails provides us an alternative for &amp;quot;centralizing dynamic decisions about the URLs&amp;quot; in its ApplicationController#default_url_options and helper methods are dependent on it (by implementing/overriding this method). This will now automatically include the locale param in the query string&lt;br /&gt;
##We can also set the locale in the URL route. For example -http://study.com/es/books .This is achievable by using over-riding default_url_options. You just have to set up your routes with scoping option in routes.rb. &lt;br /&gt;
#'''Setting the locale from client supplied information:'''&amp;lt;br&amp;gt;This can be done in 3 ways&lt;br /&gt;
##Using the default locale of the client browser&lt;br /&gt;
##Using client location to select the locale&lt;br /&gt;
##Saving the users choice of locale as a part of user profile&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Internationalizing Rails application ==&lt;br /&gt;
&lt;br /&gt;
:After your application is prepared for internationalization, we need to use the feature in our application. &lt;br /&gt;
:This can be done in the following ways:&lt;br /&gt;
&lt;br /&gt;
1. '''Adding Translations:'''&lt;br /&gt;
:In order to internationalize rails code, replace the strings with calls to  the ‘t’ helper.&amp;lt;br&amp;gt;For example: &lt;br /&gt;
 class HelloWorld &lt;br /&gt;
  def sayHello&lt;br /&gt;
    puts t(:hello_world)&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;%=t :hello_world %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:The helper method t also catches missing translations and displays appropriate error message.&lt;br /&gt;
 &amp;lt;nowiki /&amp;gt;# config/locales/en.yml&lt;br /&gt;
 en: hello_world: Hello world!&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki /&amp;gt;# config/locales/es.yml&lt;br /&gt;
 es: hello_world: hola mundo&lt;br /&gt;
&lt;br /&gt;
2. '''Passing variables to translation:'''&lt;br /&gt;
:You can use variables in the translation messages and pass their values from the view.&lt;br /&gt;
 en:&lt;br /&gt;
 portal: &amp;quot;Mypack&amp;quot;&lt;br /&gt;
   university:&lt;br /&gt;
    ncsu:&lt;br /&gt;
    description: ! 'NCSU student information is accessed on %{portal_name}’ &lt;br /&gt;
&lt;br /&gt;
 t('.description', portal_name: t(‘portal’))&lt;br /&gt;
&lt;br /&gt;
3. '''Adding date/ time formats:'''&lt;br /&gt;
:OK! Now let's add a timestamp to the view, so we can demo the date/time localization feature as well. To localize the time format you pass the Time object to I18n.l or (preferably) use ‘l’ helper. You can pick a format by passing the :format option — by default the :default format is used.&lt;br /&gt;
:In the view file:&lt;br /&gt;
 &amp;lt;%= l Time.now, format: :short %&amp;gt;&lt;br /&gt;
:In the yml file:&lt;br /&gt;
  es:&lt;br /&gt;
   time:&lt;br /&gt;
     formats:&lt;br /&gt;
       short: &amp;quot; Son las %H&amp;quot;&lt;br /&gt;
&lt;br /&gt;
4. '''Inflection rules for locales other than english:'''&lt;br /&gt;
:Rails 4.0 provides a feature to define inflection rules (singularization and pluralization)  in config/initializers/inflections.rb. &lt;br /&gt;
&lt;br /&gt;
5. '''Localized views:'''&lt;br /&gt;
:For static websites available in different languages or for large static content, localized views is a useful feature. This feature enables having separate view file for different locales. For example for default locale we can have show.html.erb file while for Spanish we can have show.es.html.erb. Thus we don’t need to maintain long .yml files for each supported locale for long static pages.&lt;br /&gt;
&lt;br /&gt;
== Internationalization Features ==&lt;br /&gt;
&lt;br /&gt;
1. '''Using Different Backends:'''&lt;br /&gt;
:The i18n provides a [http://www.ruby-doc.org/gems/docs/s/synergy_russian-0.2.8/I18n/Backend/Simple.html simple backend] by default. We can change the backend to an active records backend or chain multiple backends as per the requirements of our application. I18n gem also provides cache, fallback and pluralization feature for the backends.&lt;br /&gt;
&lt;br /&gt;
2. '''Pluralization:'''&lt;br /&gt;
:Different languages have different rules for pluralization. Thus, the I18n API provides a flexible pluralization feature.&lt;br /&gt;
&lt;br /&gt;
3. '''Fallbacks:'''&lt;br /&gt;
:In case translation for a certain  locale is missing we can define fallback chain for the locales.&lt;br /&gt;
:For example we can define a fallback chain of the form &lt;br /&gt;
 :'en-CA' =&amp;gt; :'en-US', :'en-US' =&amp;gt; :en, :de =&amp;gt; :en &lt;br /&gt;
&lt;br /&gt;
:if the translation for en-CA is missing rails looks for en-US , if en-US is missing it then looks for en and so on.&lt;br /&gt;
&lt;br /&gt;
4. '''Cascading lookups:'''&lt;br /&gt;
:If a given key is not found, it is broken and a lookup is performed for the remaining portion of the key before finally falling back to the defaults.&lt;br /&gt;
&lt;br /&gt;
5. '''Translation symlinks:'''&lt;br /&gt;
:A key can be a value for another key.&lt;br /&gt;
:Example:&lt;br /&gt;
 person: ‘ash’&lt;br /&gt;
 student: :person&lt;br /&gt;
 employee: :person&lt;br /&gt;
&lt;br /&gt;
:Ash can be an employee or a student. Each key represents the same value.&lt;br /&gt;
&lt;br /&gt;
6. '''Translation procs:'''&lt;br /&gt;
:I18n gem allows writing translation logic in the translation lookup process.&lt;br /&gt;
:For example:&lt;br /&gt;
 :en&lt;br /&gt;
  	:addressing =&amp;gt; lambda { |values|&lt;br /&gt;
 		person=values[:person]&lt;br /&gt;
 		address=person.male? ?  “Sir” : “Madam”&lt;br /&gt;
 	“Hello, #{person.address}”&lt;br /&gt;
 &lt;br /&gt;
 t(:addressing , :person =&amp;gt; mary)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
http://guides.rubyonrails.org/3_0_release_notes.html&lt;/div&gt;</summary>
		<author><name>Srparadk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w18_bs&amp;diff=76125</id>
		<title>CSC/ECE 517 Fall 2013/ch1 1w18 bs</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w18_bs&amp;diff=76125"/>
		<updated>2013-09-16T21:07:22Z</updated>

		<summary type="html">&lt;p&gt;Srparadk: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Internationalization in Rails&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
:In general when we start a conversation, the first default language of communication we use is English, but if the other person is not familiar with English we try and translate our dialogue in a language that the person is familiar with. Similarly whenever we write a program or a document we write it in English by default. But what if someone who is not familiar with English wants to read your program or code? The simple solution is that we translate program or code into a language that the person is familiar with. And for this, we use a term called internationalization.&lt;br /&gt;
&lt;br /&gt;
:Internationalization is a way by which we can view an application in various languages without actually making changes to the code of the application. This saves us a lot of time and effort, as we don’t have to write or edit the same code or document in all the copies.&lt;br /&gt;
&lt;br /&gt;
:Internationalization has an acronym, rather more of a numeronym ,which is i18n where the number 18 represents the number of letters between the first and last letters in the word internationalization.&lt;br /&gt;
&lt;br /&gt;
== Aspects to consider in Internationalization ==&lt;br /&gt;
&lt;br /&gt;
:Now when we are to change our application according to a particular language or a region , we need to keep in mind numerous points that are important, implicit, particular or sensitive to that language or region. Like for example when we take a language into consideration for which our application needs to be translated, we need to consider the spoken and written aspects of that language. Also, there might be a case when we have the same language but it differs from one region to other. For this we need to keep in mind the typical change in the use of words, grammar and symbol for each region that uses the same language. Our application must also provide support for the varied writing conventions that differ from a language to another language or from one region to another.&lt;br /&gt;
&lt;br /&gt;
:Below are the examples of the points we need to keep in mind while we provide internationalization to our application :&lt;br /&gt;
&lt;br /&gt;
* Language :&lt;br /&gt;
&lt;br /&gt;
:Here the i18n support to an application needs to provide the character encoding keeping in mind the following points:&lt;br /&gt;
&lt;br /&gt;
#The written language differs. For example most of the languages like English, French, German follow a script that can have inputs from a standard keyboard. But there are other languages like Hindi, Marathi, Sanskrit that follow a script called Devnagri and this cannot be directly typed in from a standard keyboard. So if we have to provide support for these languages we need to support the translation of the characters used in these scripts.&lt;br /&gt;
#The way we write also differs and needs to included in our i18n support. For example most of the languages follow a left-right direction while writing but some languages like Urdu tend to follow a right-left direction.&lt;br /&gt;
#The numbering symbols also vary from language to language. So when we display or accept any text with numbers, we must have i18n to support this mapping.&lt;br /&gt;
#The languages also differ in the use of grammar and structure of the sentences.For example the grammar rules and structure formation in English is way different than the one followed by another language like Sanskrit.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Culture and Writing Conventions:&lt;br /&gt;
&lt;br /&gt;
:Even if the language with the same characters and grammar is used, the use of the language , the symbols , the way of writing and many other things change with change in the region.&lt;br /&gt;
:Following are some of the examples:&lt;br /&gt;
&lt;br /&gt;
#There are some cultures that have some regulations about having a middle name as father’s name but other cultures don’t necessary include the middle name.&lt;br /&gt;
#There might be cases when there are different names or terminologies used in different cultures for the same purpose. For example, to identify a citizen uniquely US has the system of SSN while India is in the process of implementing this by using the term as Aadhar number.&lt;br /&gt;
#Another example of difference in the writing convention can be taken as that of a postal code. Some countries have 6 digit postal codes while others have 5.&lt;br /&gt;
#There is a difference in the use of many other things like the currency(like INR,dollars,Euro) used, the symbols(€,$,₹) used , the units in which the weights , temperature are measured. Another example could be the use of lakhs , crores for mentioning any financial figures in some countries while others use millions, billions.&lt;br /&gt;
#There could also be a difference in the formats used for a same thing. For example the format of writing dates and times vary from one region to another.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* We also have to be careful that we cover all the sensitive topics and issues particular to a language or region.&lt;br /&gt;
&lt;br /&gt;
:Similarly there are many other factors that we need to take care of when we support internationalization for a particular language in a particular region.&lt;br /&gt;
&lt;br /&gt;
= Internationalization in Rails =&lt;br /&gt;
&lt;br /&gt;
:Internationalization support was extended from Rails version 2.2. So in order to internationalize a rails application, it has to be migrated :to Rails 2.2 or above. Every static string in the Rails framework — e.g. Active Record validation messages, time and date formats — have :been internationalized.&lt;br /&gt;
&lt;br /&gt;
:Following needs to be done in order to internationalize a rails application:&lt;br /&gt;
:#Ensure support for internationalization by migrating to appropriate version of rails if needed.&lt;br /&gt;
:#Tell rails where to find the appropriate translations files&lt;br /&gt;
:#Tell rails how to switch locales&lt;br /&gt;
&lt;br /&gt;
::YAML (.yml) or plain Ruby (.rb) files are used for storing translations.&lt;br /&gt;
&lt;br /&gt;
== History ==&lt;br /&gt;
&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100pt&amp;quot;| Ruby 2.2    || Internationalization support was extended from this version of Rails.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 2.3    || Additional feature for Localized Views was added in this version. The view files were rendered with an extension of the locale name.I18n#available_locales and I18n::SimpleBackend#available_locales is available to retrieve an array of available locales.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 3.0    || Some additional features were added to the I18n gem for speed improvements like default translations for attributes,automatic pull for translations on form submit, etc.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 3.1    || I18n namespace lookup support removed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Ways to configure Internationalization in Rails ==&lt;br /&gt;
&lt;br /&gt;
:We can set up a rails application to support internationalization in a number of ways. Below are the various ways to configure our rails application for internationalization.&lt;br /&gt;
&lt;br /&gt;
#'''Configure the I18n module:'''&amp;lt;br&amp;gt;Rails adds all .rb and .yml files from the config/locales directory to your translations load path, automatically. This is the default setting provided by the [https://github.com/svenfuchs/i18n I18n gem]. In order to override this setting we have to make changes in the application.rb files that have instructions on how to add locales from another directory and how to set a different default locale.&lt;br /&gt;
#'''Custom I18n Configuration Setup:'''&amp;lt;br&amp;gt;Optionally, the above code can be placed anywhere in the application preferably in initializers.&lt;br /&gt;
#'''Setting and passing locale:'''&amp;lt;br&amp;gt;The above two steps help setup a default locale throughout the application. But in case we have to provide our application in different languages, we can setup the application default locale in the application.rb and then set the locale using the application-controller.rb before_action. We can then pass the locale we want as a query param for example http://study.com/books?locale=es&lt;br /&gt;
#'''Setting the locale from the domain name:'''&amp;lt;br&amp;gt;Similar to option 3 but instead of passing the locale as a query param, the locale is a part of the domain name itself. Example http://study.es&lt;br /&gt;
::You can implement it like this in your ApplicationController before_action&lt;br /&gt;
#'''Setting the locale from the URL params:'''&amp;lt;br&amp;gt;&lt;br /&gt;
##This can be a tedious task as we have to pass the locale on each request. &lt;br /&gt;
##Rails provides us an alternative for &amp;quot;centralizing dynamic decisions about the URLs&amp;quot; in its ApplicationController#default_url_options and helper methods are dependent on it (by implementing/overriding this method). This will now automatically include the locale param in the query string&lt;br /&gt;
##We can also set the locale in the URL route. For example -http://study.com/es/books .This is achievable by using over-riding default_url_options. You just have to set up your routes with scoping option in routes.rb. &lt;br /&gt;
#'''Setting the locale from client supplied information:'''&amp;lt;br&amp;gt;This can be done in 3 ways&lt;br /&gt;
##Using the default locale of the client browser&lt;br /&gt;
##Using client location to select the locale&lt;br /&gt;
##Saving the users choice of locale as a part of user profile&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Internationalizing Rails application ==&lt;br /&gt;
&lt;br /&gt;
:After your application is prepared for internationalization, we need to use the feature in our application. &lt;br /&gt;
:This can be done in the following ways:&lt;br /&gt;
&lt;br /&gt;
1. '''Adding Translations:'''&lt;br /&gt;
:In order to internationalize rails code, replace the strings with calls to  the ‘t’ helper.&amp;lt;br&amp;gt;For example: &lt;br /&gt;
 class HelloWorld &lt;br /&gt;
  def sayHello&lt;br /&gt;
    puts t(:hello_world)&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;%=t :hello_world %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:The helper method t also catches missing translations and displays appropriate error message.&lt;br /&gt;
 &amp;lt;nowiki /&amp;gt;# config/locales/en.yml&lt;br /&gt;
 en: hello_world: Hello world!&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki /&amp;gt;# config/locales/es.yml&lt;br /&gt;
 es: hello_world: hola mundo&lt;br /&gt;
&lt;br /&gt;
2. '''Passing variables to translation:'''&lt;br /&gt;
:You can use variables in the translation messages and pass their values from the view.&lt;br /&gt;
 en:&lt;br /&gt;
 portal: &amp;quot;Mypack&amp;quot;&lt;br /&gt;
   university:&lt;br /&gt;
    ncsu:&lt;br /&gt;
    description: ! 'NCSU student information is accessed on %{portal_name}’ &lt;br /&gt;
&lt;br /&gt;
 t('.description', portal_name: t(‘portal’))&lt;br /&gt;
&lt;br /&gt;
3. '''Adding date/ time formats:'''&lt;br /&gt;
:OK! Now let's add a timestamp to the view, so we can demo the date/time localization feature as well. To localize the time format you pass the Time object to I18n.l or (preferably) use ‘l’ helper. You can pick a format by passing the :format option — by default the :default format is used.&lt;br /&gt;
:In the view file:&lt;br /&gt;
 &amp;lt;%= l Time.now, format: :short %&amp;gt;&lt;br /&gt;
:In the yml file:&lt;br /&gt;
  es:&lt;br /&gt;
   time:&lt;br /&gt;
     formats:&lt;br /&gt;
       short: &amp;quot; Son las %H&amp;quot;&lt;br /&gt;
&lt;br /&gt;
4. '''Inflection rules for locales other than english:'''&lt;br /&gt;
:Rails 4.0 provides a feature to define inflection rules (singularization and pluralization)  in config/initializers/inflections.rb. &lt;br /&gt;
&lt;br /&gt;
5. '''Localized views:'''&lt;br /&gt;
:For static websites available in different languages or for large static content, localized views is a useful feature. This feature enables having separate view file for different locales. For example for default locale we can have show.html.erb file while for Spanish we can have show.es.html.erb. Thus we don’t need to maintain long .yml files for each supported locale for long static pages.&lt;br /&gt;
&lt;br /&gt;
== Internationalization Features ==&lt;br /&gt;
&lt;br /&gt;
1. '''Using Different Backends:'''&lt;br /&gt;
:The i18n provides a [http://www.ruby-doc.org/gems/docs/s/synergy_russian-0.2.8/I18n/Backend/Simple.html simple backend] by default. We can change the backend to an active records backend or chain multiple backends as per the requirements of our application. I18n gem also provides cache, fallback and pluralization feature for the backends.&lt;br /&gt;
&lt;br /&gt;
2. '''Pluralization:'''&lt;br /&gt;
:Different languages have different rules for pluralization. Thus, the I18n API provides a flexible pluralization feature.&lt;br /&gt;
&lt;br /&gt;
3. '''Fallbacks:'''&lt;br /&gt;
:In case translation for a certain  locale is missing we can define fallback chain for the locales.&lt;br /&gt;
:For example we can define a fallback chain of the form &lt;br /&gt;
 :'en-CA' =&amp;gt; :'en-US', :'en-US' =&amp;gt; :en, :de =&amp;gt; :en &lt;br /&gt;
&lt;br /&gt;
:if the translation for en-CA is missing rails looks for en-US , if en-US is missing it then looks for en and so on.&lt;br /&gt;
&lt;br /&gt;
4. '''Cascading lookups:'''&lt;br /&gt;
:If a given key is not found, it is broken and a lookup is performed for the remaining portion of the key before finally falling back to the defaults.&lt;br /&gt;
&lt;br /&gt;
5. '''Translation symlinks:'''&lt;br /&gt;
:A key can be a value for another key.&lt;br /&gt;
:Example:&lt;br /&gt;
 person: ‘ash’&lt;br /&gt;
 student: :person&lt;br /&gt;
 employee: :person&lt;br /&gt;
&lt;br /&gt;
:Ash can be an employee or a student. Each key represents the same value.&lt;br /&gt;
&lt;br /&gt;
6. '''Translation procs:'''&lt;br /&gt;
:I18n gem allows writing translation logic in the translation lookup process.&lt;br /&gt;
:For example:&lt;br /&gt;
 :en&lt;br /&gt;
  	:addressing =&amp;gt; lambda { |values|&lt;br /&gt;
 		person=values[:person]&lt;br /&gt;
 		address=person.male? ?  “Sir” : “Madam”&lt;br /&gt;
 	“Hello, #{person.address}”&lt;br /&gt;
 &lt;br /&gt;
 t(:addressing , :person =&amp;gt; mary)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
[[http://guides.rubyonrails.org/3_0_release_notes.html]]&lt;/div&gt;</summary>
		<author><name>Srparadk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w18_bs&amp;diff=76124</id>
		<title>CSC/ECE 517 Fall 2013/ch1 1w18 bs</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w18_bs&amp;diff=76124"/>
		<updated>2013-09-16T21:06:01Z</updated>

		<summary type="html">&lt;p&gt;Srparadk: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Internationalization in Rails&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
:In general when we start a conversation, the first default language of communication we use is English, but if the other person is not familiar with English we try and translate our dialogue in a language that the person is familiar with. Similarly whenever we write a program or a document we write it in English by default. But what if someone who is not familiar with English wants to read your program or code? The simple solution is that we translate program or code into a language that the person is familiar with. And for this, we use a term called internationalization.&lt;br /&gt;
&lt;br /&gt;
:Internationalization is a way by which we can view an application in various languages without actually making changes to the code of the application. This saves us a lot of time and effort, as we don’t have to write or edit the same code or document in all the copies.&lt;br /&gt;
&lt;br /&gt;
:Internationalization has an acronym, rather more of a numeronym ,which is i18n where the number 18 represents the number of letters between the first and last letters in the word internationalization.&lt;br /&gt;
&lt;br /&gt;
== Aspects to consider in Internationalization ==&lt;br /&gt;
&lt;br /&gt;
:Now when we are to change our application according to a particular language or a region , we need to keep in mind numerous points that are important, implicit, particular or sensitive to that language or region. Like for example when we take a language into consideration for which our application needs to be translated, we need to consider the spoken and written aspects of that language. Also, there might be a case when we have the same language but it differs from one region to other. For this we need to keep in mind the typical change in the use of words, grammar and symbol for each region that uses the same language. Our application must also provide support for the varied writing conventions that differ from a language to another language or from one region to another.&lt;br /&gt;
&lt;br /&gt;
:Below are the examples of the points we need to keep in mind while we provide internationalization to our application :&lt;br /&gt;
&lt;br /&gt;
* Language :&lt;br /&gt;
&lt;br /&gt;
:Here the i18n support to an application needs to provide the character encoding keeping in mind the following points:&lt;br /&gt;
&lt;br /&gt;
#The written language differs. For example most of the languages like English, French, German follow a script that can have inputs from a standard keyboard. But there are other languages like Hindi, Marathi, Sanskrit that follow a script called Devnagri and this cannot be directly typed in from a standard keyboard. So if we have to provide support for these languages we need to support the translation of the characters used in these scripts.&lt;br /&gt;
#The way we write also differs and needs to included in our i18n support. For example most of the languages follow a left-right direction while writing but some languages like Urdu tend to follow a right-left direction.&lt;br /&gt;
#The numbering symbols also vary from language to language. So when we display or accept any text with numbers, we must have i18n to support this mapping.&lt;br /&gt;
#The languages also differ in the use of grammar and structure of the sentences.For example the grammar rules and structure formation in English is way different than the one followed by another language like Sanskrit.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Culture and Writing Conventions:&lt;br /&gt;
&lt;br /&gt;
:Even if the language with the same characters and grammar is used, the use of the language , the symbols , the way of writing and many other things change with change in the region.&lt;br /&gt;
:Following are some of the examples:&lt;br /&gt;
&lt;br /&gt;
#There are some cultures that have some regulations about having a middle name as father’s name but other cultures don’t necessary include the middle name.&lt;br /&gt;
#There might be cases when there are different names or terminologies used in different cultures for the same purpose. For example, to identify a citizen uniquely US has the system of SSN while India is in the process of implementing this by using the term as Aadhar number.&lt;br /&gt;
#Another example of difference in the writing convention can be taken as that of a postal code. Some countries have 6 digit postal codes while others have 5.&lt;br /&gt;
#There is a difference in the use of many other things like the currency(like INR,dollars,Euro) used, the symbols(€,$,₹) used , the units in which the weights , temperature are measured. Another example could be the use of lakhs , crores for mentioning any financial figures in some countries while others use millions, billions.&lt;br /&gt;
#There could also be a difference in the formats used for a same thing. For example the format of writing dates and times vary from one region to another.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* We also have to be careful that we cover all the sensitive topics and issues particular to a language or region.&lt;br /&gt;
&lt;br /&gt;
:Similarly there are many other factors that we need to take care of when we support internationalization for a particular language in a particular region.&lt;br /&gt;
&lt;br /&gt;
= Internationalization in Rails =&lt;br /&gt;
&lt;br /&gt;
:Internationalization support was extended from Rails version 2.2. So in order to internationalize a rails application, it has to be migrated :to Rails 2.2 or above. Every static string in the Rails framework — e.g. Active Record validation messages, time and date formats — have :been internationalized.&lt;br /&gt;
&lt;br /&gt;
:Following needs to be done in order to internationalize a rails application:&lt;br /&gt;
:#Ensure support for internationalization by migrating to appropriate version of rails if needed.&lt;br /&gt;
:#Tell rails where to find the appropriate translations files&lt;br /&gt;
:#Tell rails how to switch locales&lt;br /&gt;
&lt;br /&gt;
::YAML (.yml) or plain Ruby (.rb) files are used for storing translations.&lt;br /&gt;
&lt;br /&gt;
== History ==&lt;br /&gt;
&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100pt&amp;quot;| Ruby 2.2    || Internationalization support was extended from this version of Rails.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 2.3    || Additional feature for Localized Views was added in this version. The view files were rendered with an extension of the locale name.I18n#available_locales and I18n::SimpleBackend#available_locales is available to retrieve an array of available locales.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 3.0    || Some additional features were added to the I18n gem for speed improvements like default translations for attributes,automatic pull for translations on form submit, etc.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 3.1    || I18n namespace lookup support removed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Ways to configure Internationalization in Rails ==&lt;br /&gt;
&lt;br /&gt;
:We can set up a rails application to support internationalization in a number of ways. Below are the various ways to configure our rails application for internationalization.&lt;br /&gt;
&lt;br /&gt;
#'''Configure the I18n module:'''&amp;lt;br&amp;gt;Rails adds all .rb and .yml files from the config/locales directory to your translations load path, automatically. This is the default setting provided by the [https://github.com/svenfuchs/i18n I18n gem]. In order to override this setting we have to make changes in the application.rb files that have instructions on how to add locales from another directory and how to set a different default locale.&lt;br /&gt;
#'''Custom I18n Configuration Setup:'''&amp;lt;br&amp;gt;Optionally, the above code can be placed anywhere in the application preferably in initializers.&lt;br /&gt;
#'''Setting and passing locale:'''&amp;lt;br&amp;gt;The above two steps help setup a default locale throughout the application. But in case we have to provide our application in different languages, we can setup the application default locale in the application.rb and then set the locale using the application-controller.rb before_action. We can then pass the locale we want as a query param for example http://study.com/books?locale=es&lt;br /&gt;
#'''Setting the locale from the domain name:'''&amp;lt;br&amp;gt;Similar to option 3 but instead of passing the locale as a query param, the locale is a part of the domain name itself. Example http://study.es&lt;br /&gt;
::You can implement it like this in your ApplicationController before_action&lt;br /&gt;
#'''Setting the locale from the URL params:'''&amp;lt;br&amp;gt;&lt;br /&gt;
##This can be a tedious task as we have to pass the locale on each request. &lt;br /&gt;
##Rails provides us an alternative for &amp;quot;centralizing dynamic decisions about the URLs&amp;quot; in its ApplicationController#default_url_options and helper methods are dependent on it (by implementing/overriding this method). This will now automatically include the locale param in the query string&lt;br /&gt;
##We can also set the locale in the URL route. For example -http://study.com/es/books .This is achievable by using over-riding default_url_options. You just have to set up your routes with scoping option in routes.rb. &lt;br /&gt;
#'''Setting the locale from client supplied information:'''&amp;lt;br&amp;gt;This can be done in 3 ways&lt;br /&gt;
##Using the default locale of the client browser&lt;br /&gt;
##Using client location to select the locale&lt;br /&gt;
##Saving the users choice of locale as a part of user profile&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Internationalizing Rails application ==&lt;br /&gt;
&lt;br /&gt;
:After your application is prepared for internationalization, we need to use the feature in our application. &lt;br /&gt;
:This can be done in the following ways:&lt;br /&gt;
&lt;br /&gt;
1. '''Adding Translations:'''&lt;br /&gt;
:In order to internationalize rails code, replace the strings with calls to  the ‘t’ helper.&amp;lt;br&amp;gt;For example: &lt;br /&gt;
 class HelloWorld &lt;br /&gt;
  def sayHello&lt;br /&gt;
    puts t(:hello_world)&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;%=t :hello_world %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:The helper method t also catches missing translations and displays appropriate error message.&lt;br /&gt;
 &amp;lt;nowiki /&amp;gt;# config/locales/en.yml&lt;br /&gt;
 en: hello_world: Hello world!&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki /&amp;gt;# config/locales/es.yml&lt;br /&gt;
 es: hello_world: hola mundo&lt;br /&gt;
&lt;br /&gt;
2. '''Passing variables to translation:'''&lt;br /&gt;
:You can use variables in the translation messages and pass their values from the view.&lt;br /&gt;
 en:&lt;br /&gt;
 portal: &amp;quot;Mypack&amp;quot;&lt;br /&gt;
   university:&lt;br /&gt;
    ncsu:&lt;br /&gt;
    description: ! 'NCSU student information is accessed on %{portal_name}’ &lt;br /&gt;
&lt;br /&gt;
 t('.description', portal_name: t(‘portal’))&lt;br /&gt;
&lt;br /&gt;
3. '''Adding date/ time formats:'''&lt;br /&gt;
:OK! Now let's add a timestamp to the view, so we can demo the date/time localization feature as well. To localize the time format you pass the Time object to I18n.l or (preferably) use ‘l’ helper. You can pick a format by passing the :format option — by default the :default format is used.&lt;br /&gt;
:In the view file:&lt;br /&gt;
 &amp;lt;%= l Time.now, format: :short %&amp;gt;&lt;br /&gt;
:In the yml file:&lt;br /&gt;
  es:&lt;br /&gt;
   time:&lt;br /&gt;
     formats:&lt;br /&gt;
       short: &amp;quot; Son las %H&amp;quot;&lt;br /&gt;
&lt;br /&gt;
4. '''Inflection rules for locales other than english:'''&lt;br /&gt;
:Rails 4.0 provides a feature to define inflection rules (singularization and pluralization)  in config/initializers/inflections.rb. &lt;br /&gt;
&lt;br /&gt;
5. '''Localized views:'''&lt;br /&gt;
:For static websites available in different languages or for large static content, localized views is a useful feature. This feature enables having separate view file for different locales. For example for default locale we can have show.html.erb file while for Spanish we can have show.es.html.erb. Thus we don’t need to maintain long .yml files for each supported locale for long static pages.&lt;br /&gt;
&lt;br /&gt;
== Internationalization Features ==&lt;br /&gt;
&lt;br /&gt;
1. '''Using Different Backends:'''&lt;br /&gt;
:The i18n provides a [http://www.ruby-doc.org/gems/docs/s/synergy_russian-0.2.8/I18n/Backend/Simple.html simple backend] by default. We can change the backend to an active records backend or chain multiple backends as per the requirements of our application. I18n gem also provides cache, fallback and pluralization feature for the backends.&lt;br /&gt;
&lt;br /&gt;
2. '''Pluralization:'''&lt;br /&gt;
:Different languages have different rules for pluralization. Thus, the I18n API provides a flexible pluralization feature.&lt;br /&gt;
&lt;br /&gt;
3. '''Fallbacks:'''&lt;br /&gt;
:In case translation for a certain  locale is missing we can define fallback chain for the locales.&lt;br /&gt;
:For example we can define a fallback chain of the form &lt;br /&gt;
 :'en-CA' =&amp;gt; :'en-US', :'en-US' =&amp;gt; :en, :de =&amp;gt; :en &lt;br /&gt;
&lt;br /&gt;
:if the translation for en-CA is missing rails looks for en-US , if en-US is missing it then looks for en and so on.&lt;br /&gt;
&lt;br /&gt;
4. '''Cascading lookups:'''&lt;br /&gt;
:If a given key is not found, it is broken and a lookup is performed for the remaining portion of the key before finally falling back to the defaults.&lt;br /&gt;
&lt;br /&gt;
5. '''Translation symlinks:'''&lt;br /&gt;
:A key can be a value for another key.&lt;br /&gt;
:Example:&lt;br /&gt;
 person: ‘ash’&lt;br /&gt;
 student: :person&lt;br /&gt;
 employee: :person&lt;br /&gt;
&lt;br /&gt;
:Ash can be an employee or a student. Each key represents the same value.&lt;br /&gt;
&lt;br /&gt;
6. '''Translation procs:'''&lt;br /&gt;
:I18n gem allows writing translation logic in the translation lookup process.&lt;br /&gt;
:For example:&lt;br /&gt;
 :en&lt;br /&gt;
  	:addressing =&amp;gt; lambda { |values|&lt;br /&gt;
 		person=values[:person]&lt;br /&gt;
 		address=person.male? ?  “Sir” : “Madam”&lt;br /&gt;
 	“Hello, #{person.address}”&lt;br /&gt;
 &lt;br /&gt;
 t(:addressing , :person =&amp;gt; mary)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
[http://guides.rubyonrails.org/3_0_release_notes.html ]&lt;/div&gt;</summary>
		<author><name>Srparadk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w18_bs&amp;diff=76123</id>
		<title>CSC/ECE 517 Fall 2013/ch1 1w18 bs</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w18_bs&amp;diff=76123"/>
		<updated>2013-09-16T21:05:47Z</updated>

		<summary type="html">&lt;p&gt;Srparadk: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Internationalization in Rails&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
:In general when we start a conversation, the first default language of communication we use is English, but if the other person is not familiar with English we try and translate our dialogue in a language that the person is familiar with. Similarly whenever we write a program or a document we write it in English by default. But what if someone who is not familiar with English wants to read your program or code? The simple solution is that we translate program or code into a language that the person is familiar with. And for this, we use a term called internationalization.&lt;br /&gt;
&lt;br /&gt;
:Internationalization is a way by which we can view an application in various languages without actually making changes to the code of the application. This saves us a lot of time and effort, as we don’t have to write or edit the same code or document in all the copies.&lt;br /&gt;
&lt;br /&gt;
:Internationalization has an acronym, rather more of a numeronym ,which is i18n where the number 18 represents the number of letters between the first and last letters in the word internationalization.&lt;br /&gt;
&lt;br /&gt;
== Aspects to consider in Internationalization ==&lt;br /&gt;
&lt;br /&gt;
:Now when we are to change our application according to a particular language or a region , we need to keep in mind numerous points that are important, implicit, particular or sensitive to that language or region. Like for example when we take a language into consideration for which our application needs to be translated, we need to consider the spoken and written aspects of that language. Also, there might be a case when we have the same language but it differs from one region to other. For this we need to keep in mind the typical change in the use of words, grammar and symbol for each region that uses the same language. Our application must also provide support for the varied writing conventions that differ from a language to another language or from one region to another.&lt;br /&gt;
&lt;br /&gt;
:Below are the examples of the points we need to keep in mind while we provide internationalization to our application :&lt;br /&gt;
&lt;br /&gt;
* Language :&lt;br /&gt;
&lt;br /&gt;
:Here the i18n support to an application needs to provide the character encoding keeping in mind the following points:&lt;br /&gt;
&lt;br /&gt;
#The written language differs. For example most of the languages like English, French, German follow a script that can have inputs from a standard keyboard. But there are other languages like Hindi, Marathi, Sanskrit that follow a script called Devnagri and this cannot be directly typed in from a standard keyboard. So if we have to provide support for these languages we need to support the translation of the characters used in these scripts.&lt;br /&gt;
#The way we write also differs and needs to included in our i18n support. For example most of the languages follow a left-right direction while writing but some languages like Urdu tend to follow a right-left direction.&lt;br /&gt;
#The numbering symbols also vary from language to language. So when we display or accept any text with numbers, we must have i18n to support this mapping.&lt;br /&gt;
#The languages also differ in the use of grammar and structure of the sentences.For example the grammar rules and structure formation in English is way different than the one followed by another language like Sanskrit.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Culture and Writing Conventions:&lt;br /&gt;
&lt;br /&gt;
:Even if the language with the same characters and grammar is used, the use of the language , the symbols , the way of writing and many other things change with change in the region.&lt;br /&gt;
:Following are some of the examples:&lt;br /&gt;
&lt;br /&gt;
#There are some cultures that have some regulations about having a middle name as father’s name but other cultures don’t necessary include the middle name.&lt;br /&gt;
#There might be cases when there are different names or terminologies used in different cultures for the same purpose. For example, to identify a citizen uniquely US has the system of SSN while India is in the process of implementing this by using the term as Aadhar number.&lt;br /&gt;
#Another example of difference in the writing convention can be taken as that of a postal code. Some countries have 6 digit postal codes while others have 5.&lt;br /&gt;
#There is a difference in the use of many other things like the currency(like INR,dollars,Euro) used, the symbols(€,$,₹) used , the units in which the weights , temperature are measured. Another example could be the use of lakhs , crores for mentioning any financial figures in some countries while others use millions, billions.&lt;br /&gt;
#There could also be a difference in the formats used for a same thing. For example the format of writing dates and times vary from one region to another.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* We also have to be careful that we cover all the sensitive topics and issues particular to a language or region.&lt;br /&gt;
&lt;br /&gt;
:Similarly there are many other factors that we need to take care of when we support internationalization for a particular language in a particular region.&lt;br /&gt;
&lt;br /&gt;
= Internationalization in Rails =&lt;br /&gt;
&lt;br /&gt;
:Internationalization support was extended from Rails version 2.2. So in order to internationalize a rails application, it has to be migrated :to Rails 2.2 or above. Every static string in the Rails framework — e.g. Active Record validation messages, time and date formats — have :been internationalized.&lt;br /&gt;
&lt;br /&gt;
:Following needs to be done in order to internationalize a rails application:&lt;br /&gt;
:#Ensure support for internationalization by migrating to appropriate version of rails if needed.&lt;br /&gt;
:#Tell rails where to find the appropriate translations files&lt;br /&gt;
:#Tell rails how to switch locales&lt;br /&gt;
&lt;br /&gt;
::YAML (.yml) or plain Ruby (.rb) files are used for storing translations.&lt;br /&gt;
&lt;br /&gt;
== History ==&lt;br /&gt;
&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100pt&amp;quot;| Ruby 2.2    || Internationalization support was extended from this version of Rails.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 2.3    || Additional feature for Localized Views was added in this version. The view files were rendered with an extension of the locale name.I18n#available_locales and I18n::SimpleBackend#available_locales is available to retrieve an array of available locales.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 3.0    || Some additional features were added to the I18n gem for speed improvements like default translations for attributes,automatic pull for translations on form submit, etc.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 3.1    || I18n namespace lookup support removed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Ways to configure Internationalization in Rails ==&lt;br /&gt;
&lt;br /&gt;
:We can set up a rails application to support internationalization in a number of ways. Below are the various ways to configure our rails application for internationalization.&lt;br /&gt;
&lt;br /&gt;
#'''Configure the I18n module:'''&amp;lt;br&amp;gt;Rails adds all .rb and .yml files from the config/locales directory to your translations load path, automatically. This is the default setting provided by the [https://github.com/svenfuchs/i18n I18n gem]. In order to override this setting we have to make changes in the application.rb files that have instructions on how to add locales from another directory and how to set a different default locale.&lt;br /&gt;
#'''Custom I18n Configuration Setup:'''&amp;lt;br&amp;gt;Optionally, the above code can be placed anywhere in the application preferably in initializers.&lt;br /&gt;
#'''Setting and passing locale:'''&amp;lt;br&amp;gt;The above two steps help setup a default locale throughout the application. But in case we have to provide our application in different languages, we can setup the application default locale in the application.rb and then set the locale using the application-controller.rb before_action. We can then pass the locale we want as a query param for example http://study.com/books?locale=es&lt;br /&gt;
#'''Setting the locale from the domain name:'''&amp;lt;br&amp;gt;Similar to option 3 but instead of passing the locale as a query param, the locale is a part of the domain name itself. Example http://study.es&lt;br /&gt;
::You can implement it like this in your ApplicationController before_action&lt;br /&gt;
#'''Setting the locale from the URL params:'''&amp;lt;br&amp;gt;&lt;br /&gt;
##This can be a tedious task as we have to pass the locale on each request. &lt;br /&gt;
##Rails provides us an alternative for &amp;quot;centralizing dynamic decisions about the URLs&amp;quot; in its ApplicationController#default_url_options and helper methods are dependent on it (by implementing/overriding this method). This will now automatically include the locale param in the query string&lt;br /&gt;
##We can also set the locale in the URL route. For example -http://study.com/es/books .This is achievable by using over-riding default_url_options. You just have to set up your routes with scoping option in routes.rb. &lt;br /&gt;
#'''Setting the locale from client supplied information:'''&amp;lt;br&amp;gt;This can be done in 3 ways&lt;br /&gt;
##Using the default locale of the client browser&lt;br /&gt;
##Using client location to select the locale&lt;br /&gt;
##Saving the users choice of locale as a part of user profile&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Internationalizing Rails application ==&lt;br /&gt;
&lt;br /&gt;
:After your application is prepared for internationalization, we need to use the feature in our application. &lt;br /&gt;
:This can be done in the following ways:&lt;br /&gt;
&lt;br /&gt;
1. '''Adding Translations:'''&lt;br /&gt;
:In order to internationalize rails code, replace the strings with calls to  the ‘t’ helper.&amp;lt;br&amp;gt;For example: &lt;br /&gt;
 class HelloWorld &lt;br /&gt;
  def sayHello&lt;br /&gt;
    puts t(:hello_world)&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;%=t :hello_world %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:The helper method t also catches missing translations and displays appropriate error message.&lt;br /&gt;
 &amp;lt;nowiki /&amp;gt;# config/locales/en.yml&lt;br /&gt;
 en: hello_world: Hello world!&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki /&amp;gt;# config/locales/es.yml&lt;br /&gt;
 es: hello_world: hola mundo&lt;br /&gt;
&lt;br /&gt;
2. '''Passing variables to translation:'''&lt;br /&gt;
:You can use variables in the translation messages and pass their values from the view.&lt;br /&gt;
 en:&lt;br /&gt;
 portal: &amp;quot;Mypack&amp;quot;&lt;br /&gt;
   university:&lt;br /&gt;
    ncsu:&lt;br /&gt;
    description: ! 'NCSU student information is accessed on %{portal_name}’ &lt;br /&gt;
&lt;br /&gt;
 t('.description', portal_name: t(‘portal’))&lt;br /&gt;
&lt;br /&gt;
3. '''Adding date/ time formats:'''&lt;br /&gt;
:OK! Now let's add a timestamp to the view, so we can demo the date/time localization feature as well. To localize the time format you pass the Time object to I18n.l or (preferably) use ‘l’ helper. You can pick a format by passing the :format option — by default the :default format is used.&lt;br /&gt;
:In the view file:&lt;br /&gt;
 &amp;lt;%= l Time.now, format: :short %&amp;gt;&lt;br /&gt;
:In the yml file:&lt;br /&gt;
  es:&lt;br /&gt;
   time:&lt;br /&gt;
     formats:&lt;br /&gt;
       short: &amp;quot; Son las %H&amp;quot;&lt;br /&gt;
&lt;br /&gt;
4. '''Inflection rules for locales other than english:'''&lt;br /&gt;
:Rails 4.0 provides a feature to define inflection rules (singularization and pluralization)  in config/initializers/inflections.rb. &lt;br /&gt;
&lt;br /&gt;
5. '''Localized views:'''&lt;br /&gt;
:For static websites available in different languages or for large static content, localized views is a useful feature. This feature enables having separate view file for different locales. For example for default locale we can have show.html.erb file while for Spanish we can have show.es.html.erb. Thus we don’t need to maintain long .yml files for each supported locale for long static pages.&lt;br /&gt;
&lt;br /&gt;
== Internationalization Features ==&lt;br /&gt;
&lt;br /&gt;
1. '''Using Different Backends:'''&lt;br /&gt;
:The i18n provides a [http://www.ruby-doc.org/gems/docs/s/synergy_russian-0.2.8/I18n/Backend/Simple.html simple backend] by default. We can change the backend to an active records backend or chain multiple backends as per the requirements of our application. I18n gem also provides cache, fallback and pluralization feature for the backends.&lt;br /&gt;
&lt;br /&gt;
2. '''Pluralization:'''&lt;br /&gt;
:Different languages have different rules for pluralization. Thus, the I18n API provides a flexible pluralization feature.&lt;br /&gt;
&lt;br /&gt;
3. '''Fallbacks:'''&lt;br /&gt;
:In case translation for a certain  locale is missing we can define fallback chain for the locales.&lt;br /&gt;
:For example we can define a fallback chain of the form &lt;br /&gt;
 :'en-CA' =&amp;gt; :'en-US', :'en-US' =&amp;gt; :en, :de =&amp;gt; :en &lt;br /&gt;
&lt;br /&gt;
:if the translation for en-CA is missing rails looks for en-US , if en-US is missing it then looks for en and so on.&lt;br /&gt;
&lt;br /&gt;
4. '''Cascading lookups:'''&lt;br /&gt;
:If a given key is not found, it is broken and a lookup is performed for the remaining portion of the key before finally falling back to the defaults.&lt;br /&gt;
&lt;br /&gt;
5. '''Translation symlinks:'''&lt;br /&gt;
:A key can be a value for another key.&lt;br /&gt;
:Example:&lt;br /&gt;
 person: ‘ash’&lt;br /&gt;
 student: :person&lt;br /&gt;
 employee: :person&lt;br /&gt;
&lt;br /&gt;
:Ash can be an employee or a student. Each key represents the same value.&lt;br /&gt;
&lt;br /&gt;
6. '''Translation procs:'''&lt;br /&gt;
:I18n gem allows writing translation logic in the translation lookup process.&lt;br /&gt;
:For example:&lt;br /&gt;
 :en&lt;br /&gt;
  	:addressing =&amp;gt; lambda { |values|&lt;br /&gt;
 		person=values[:person]&lt;br /&gt;
 		address=person.male? ?  “Sir” : “Madam”&lt;br /&gt;
 	“Hello, #{person.address}”&lt;br /&gt;
 &lt;br /&gt;
 t(:addressing , :person =&amp;gt; mary)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
[http://guides.rubyonrails.org/3_0_release_notes.html |]&lt;/div&gt;</summary>
		<author><name>Srparadk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w18_bs&amp;diff=76122</id>
		<title>CSC/ECE 517 Fall 2013/ch1 1w18 bs</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w18_bs&amp;diff=76122"/>
		<updated>2013-09-16T21:04:50Z</updated>

		<summary type="html">&lt;p&gt;Srparadk: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Internationalization in Rails&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
:In general when we start a conversation, the first default language of communication we use is English, but if the other person is not familiar with English we try and translate our dialogue in a language that the person is familiar with. Similarly whenever we write a program or a document we write it in English by default. But what if someone who is not familiar with English wants to read your program or code? The simple solution is that we translate program or code into a language that the person is familiar with. And for this, we use a term called internationalization.&lt;br /&gt;
&lt;br /&gt;
:Internationalization is a way by which we can view an application in various languages without actually making changes to the code of the application. This saves us a lot of time and effort, as we don’t have to write or edit the same code or document in all the copies.&lt;br /&gt;
&lt;br /&gt;
:Internationalization has an acronym, rather more of a numeronym ,which is i18n where the number 18 represents the number of letters between the first and last letters in the word internationalization.&lt;br /&gt;
&lt;br /&gt;
== Aspects to consider in Internationalization ==&lt;br /&gt;
&lt;br /&gt;
:Now when we are to change our application according to a particular language or a region , we need to keep in mind numerous points that are important, implicit, particular or sensitive to that language or region. Like for example when we take a language into consideration for which our application needs to be translated, we need to consider the spoken and written aspects of that language. Also, there might be a case when we have the same language but it differs from one region to other. For this we need to keep in mind the typical change in the use of words, grammar and symbol for each region that uses the same language. Our application must also provide support for the varied writing conventions that differ from a language to another language or from one region to another.&lt;br /&gt;
&lt;br /&gt;
:Below are the examples of the points we need to keep in mind while we provide internationalization to our application :&lt;br /&gt;
&lt;br /&gt;
* Language :&lt;br /&gt;
&lt;br /&gt;
:Here the i18n support to an application needs to provide the character encoding keeping in mind the following points:&lt;br /&gt;
&lt;br /&gt;
#The written language differs. For example most of the languages like English, French, German follow a script that can have inputs from a standard keyboard. But there are other languages like Hindi, Marathi, Sanskrit that follow a script called Devnagri and this cannot be directly typed in from a standard keyboard. So if we have to provide support for these languages we need to support the translation of the characters used in these scripts.&lt;br /&gt;
#The way we write also differs and needs to included in our i18n support. For example most of the languages follow a left-right direction while writing but some languages like Urdu tend to follow a right-left direction.&lt;br /&gt;
#The numbering symbols also vary from language to language. So when we display or accept any text with numbers, we must have i18n to support this mapping.&lt;br /&gt;
#The languages also differ in the use of grammar and structure of the sentences.For example the grammar rules and structure formation in English is way different than the one followed by another language like Sanskrit.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Culture and Writing Conventions:&lt;br /&gt;
&lt;br /&gt;
:Even if the language with the same characters and grammar is used, the use of the language , the symbols , the way of writing and many other things change with change in the region.&lt;br /&gt;
:Following are some of the examples:&lt;br /&gt;
&lt;br /&gt;
#There are some cultures that have some regulations about having a middle name as father’s name but other cultures don’t necessary include the middle name.&lt;br /&gt;
#There might be cases when there are different names or terminologies used in different cultures for the same purpose. For example, to identify a citizen uniquely US has the system of SSN while India is in the process of implementing this by using the term as Aadhar number.&lt;br /&gt;
#Another example of difference in the writing convention can be taken as that of a postal code. Some countries have 6 digit postal codes while others have 5.&lt;br /&gt;
#There is a difference in the use of many other things like the currency(like INR,dollars,Euro) used, the symbols(€,$,₹) used , the units in which the weights , temperature are measured. Another example could be the use of lakhs , crores for mentioning any financial figures in some countries while others use millions, billions.&lt;br /&gt;
#There could also be a difference in the formats used for a same thing. For example the format of writing dates and times vary from one region to another.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* We also have to be careful that we cover all the sensitive topics and issues particular to a language or region.&lt;br /&gt;
&lt;br /&gt;
:Similarly there are many other factors that we need to take care of when we support internationalization for a particular language in a particular region.&lt;br /&gt;
&lt;br /&gt;
= Internationalization in Rails =&lt;br /&gt;
&lt;br /&gt;
:Internationalization support was extended from Rails version 2.2. So in order to internationalize a rails application, it has to be migrated :to Rails 2.2 or above. Every static string in the Rails framework — e.g. Active Record validation messages, time and date formats — have :been internationalized.&lt;br /&gt;
&lt;br /&gt;
:Following needs to be done in order to internationalize a rails application:&lt;br /&gt;
:#Ensure support for internationalization by migrating to appropriate version of rails if needed.&lt;br /&gt;
:#Tell rails where to find the appropriate translations files&lt;br /&gt;
:#Tell rails how to switch locales&lt;br /&gt;
&lt;br /&gt;
::YAML (.yml) or plain Ruby (.rb) files are used for storing translations.&lt;br /&gt;
&lt;br /&gt;
== History ==&lt;br /&gt;
&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100pt&amp;quot;| Ruby 2.2    || Internationalization support was extended from this version of Rails.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 2.3    || Additional feature for Localized Views was added in this version. The view files were rendered with an extension of the locale name.I18n#available_locales and I18n::SimpleBackend#available_locales is available to retrieve an array of available locales.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 3.0    || Some additional features were added to the I18n gem for speed improvements like default translations for attributes,automatic pull for translations on form submit, etc.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 3.1    || I18n namespace lookup support removed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Ways to configure Internationalization in Rails ==&lt;br /&gt;
&lt;br /&gt;
:We can set up a rails application to support internationalization in a number of ways. Below are the various ways to configure our rails application for internationalization.&lt;br /&gt;
&lt;br /&gt;
#'''Configure the I18n module:'''&amp;lt;br&amp;gt;Rails adds all .rb and .yml files from the config/locales directory to your translations load path, automatically. This is the default setting provided by the [https://github.com/svenfuchs/i18n I18n gem]. In order to override this setting we have to make changes in the application.rb files that have instructions on how to add locales from another directory and how to set a different default locale.&lt;br /&gt;
#'''Custom I18n Configuration Setup:'''&amp;lt;br&amp;gt;Optionally, the above code can be placed anywhere in the application preferably in initializers.&lt;br /&gt;
#'''Setting and passing locale:'''&amp;lt;br&amp;gt;The above two steps help setup a default locale throughout the application. But in case we have to provide our application in different languages, we can setup the application default locale in the application.rb and then set the locale using the application-controller.rb before_action. We can then pass the locale we want as a query param for example http://study.com/books?locale=es&lt;br /&gt;
#'''Setting the locale from the domain name:'''&amp;lt;br&amp;gt;Similar to option 3 but instead of passing the locale as a query param, the locale is a part of the domain name itself. Example http://study.es&lt;br /&gt;
::You can implement it like this in your ApplicationController before_action&lt;br /&gt;
#'''Setting the locale from the URL params:'''&amp;lt;br&amp;gt;&lt;br /&gt;
##This can be a tedious task as we have to pass the locale on each request. &lt;br /&gt;
##Rails provides us an alternative for &amp;quot;centralizing dynamic decisions about the URLs&amp;quot; in its ApplicationController#default_url_options and helper methods are dependent on it (by implementing/overriding this method). This will now automatically include the locale param in the query string&lt;br /&gt;
##We can also set the locale in the URL route. For example -http://study.com/es/books .This is achievable by using over-riding default_url_options. You just have to set up your routes with scoping option in routes.rb. &lt;br /&gt;
#'''Setting the locale from client supplied information:'''&amp;lt;br&amp;gt;This can be done in 3 ways&lt;br /&gt;
##Using the default locale of the client browser&lt;br /&gt;
##Using client location to select the locale&lt;br /&gt;
##Saving the users choice of locale as a part of user profile&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Internationalizing Rails application ==&lt;br /&gt;
&lt;br /&gt;
:After your application is prepared for internationalization, we need to use the feature in our application. &lt;br /&gt;
:This can be done in the following ways:&lt;br /&gt;
&lt;br /&gt;
1. '''Adding Translations:'''&lt;br /&gt;
:In order to internationalize rails code, replace the strings with calls to  the ‘t’ helper.&amp;lt;br&amp;gt;For example: &lt;br /&gt;
 class HelloWorld &lt;br /&gt;
  def sayHello&lt;br /&gt;
    puts t(:hello_world)&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;%=t :hello_world %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:The helper method t also catches missing translations and displays appropriate error message.&lt;br /&gt;
 &amp;lt;nowiki /&amp;gt;# config/locales/en.yml&lt;br /&gt;
 en: hello_world: Hello world!&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki /&amp;gt;# config/locales/es.yml&lt;br /&gt;
 es: hello_world: hola mundo&lt;br /&gt;
&lt;br /&gt;
2. '''Passing variables to translation:'''&lt;br /&gt;
:You can use variables in the translation messages and pass their values from the view.&lt;br /&gt;
 en:&lt;br /&gt;
 portal: &amp;quot;Mypack&amp;quot;&lt;br /&gt;
   university:&lt;br /&gt;
    ncsu:&lt;br /&gt;
    description: ! 'NCSU student information is accessed on %{portal_name}’ &lt;br /&gt;
&lt;br /&gt;
 t('.description', portal_name: t(‘portal’))&lt;br /&gt;
&lt;br /&gt;
3. '''Adding date/ time formats:'''&lt;br /&gt;
:OK! Now let's add a timestamp to the view, so we can demo the date/time localization feature as well. To localize the time format you pass the Time object to I18n.l or (preferably) use ‘l’ helper. You can pick a format by passing the :format option — by default the :default format is used.&lt;br /&gt;
:In the view file:&lt;br /&gt;
 &amp;lt;%= l Time.now, format: :short %&amp;gt;&lt;br /&gt;
:In the yml file:&lt;br /&gt;
  es:&lt;br /&gt;
   time:&lt;br /&gt;
     formats:&lt;br /&gt;
       short: &amp;quot; Son las %H&amp;quot;&lt;br /&gt;
&lt;br /&gt;
4. '''Inflection rules for locales other than english:'''&lt;br /&gt;
:Rails 4.0 provides a feature to define inflection rules (singularization and pluralization)  in config/initializers/inflections.rb. &lt;br /&gt;
&lt;br /&gt;
5. '''Localized views:'''&lt;br /&gt;
:For static websites available in different languages or for large static content, localized views is a useful feature. This feature enables having separate view file for different locales. For example for default locale we can have show.html.erb file while for Spanish we can have show.es.html.erb. Thus we don’t need to maintain long .yml files for each supported locale for long static pages.&lt;br /&gt;
&lt;br /&gt;
== Internationalization Features ==&lt;br /&gt;
&lt;br /&gt;
1. '''Using Different Backends:'''&lt;br /&gt;
:The i18n provides a [http://www.ruby-doc.org/gems/docs/s/synergy_russian-0.2.8/I18n/Backend/Simple.html simple backend] by default. We can change the backend to an active records backend or chain multiple backends as per the requirements of our application. I18n gem also provides cache, fallback and pluralization feature for the backends.&lt;br /&gt;
&lt;br /&gt;
2. '''Pluralization:'''&lt;br /&gt;
:Different languages have different rules for pluralization. Thus, the I18n API provides a flexible pluralization feature.&lt;br /&gt;
&lt;br /&gt;
3. '''Fallbacks:'''&lt;br /&gt;
:In case translation for a certain  locale is missing we can define fallback chain for the locales.&lt;br /&gt;
:For example we can define a fallback chain of the form &lt;br /&gt;
 :'en-CA' =&amp;gt; :'en-US', :'en-US' =&amp;gt; :en, :de =&amp;gt; :en &lt;br /&gt;
&lt;br /&gt;
:if the translation for en-CA is missing rails looks for en-US , if en-US is missing it then looks for en and so on.&lt;br /&gt;
&lt;br /&gt;
4. '''Cascading lookups:'''&lt;br /&gt;
:If a given key is not found, it is broken and a lookup is performed for the remaining portion of the key before finally falling back to the defaults.&lt;br /&gt;
&lt;br /&gt;
5. '''Translation symlinks:'''&lt;br /&gt;
:A key can be a value for another key.&lt;br /&gt;
:Example:&lt;br /&gt;
 person: ‘ash’&lt;br /&gt;
 student: :person&lt;br /&gt;
 employee: :person&lt;br /&gt;
&lt;br /&gt;
:Ash can be an employee or a student. Each key represents the same value.&lt;br /&gt;
&lt;br /&gt;
6. '''Translation procs:'''&lt;br /&gt;
:I18n gem allows writing translation logic in the translation lookup process.&lt;br /&gt;
:For example:&lt;br /&gt;
 :en&lt;br /&gt;
  	:addressing =&amp;gt; lambda { |values|&lt;br /&gt;
 		person=values[:person]&lt;br /&gt;
 		address=person.male? ?  “Sir” : “Madam”&lt;br /&gt;
 	“Hello, #{person.address}”&lt;br /&gt;
 &lt;br /&gt;
 t(:addressing , :person =&amp;gt; mary)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
[http://guides.rubyonrails.org/3_0_release_notes.html]&lt;/div&gt;</summary>
		<author><name>Srparadk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w18_bs&amp;diff=76119</id>
		<title>CSC/ECE 517 Fall 2013/ch1 1w18 bs</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w18_bs&amp;diff=76119"/>
		<updated>2013-09-16T21:02:47Z</updated>

		<summary type="html">&lt;p&gt;Srparadk: /* Internationalization Features */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Internationalization in Rails&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
:In general when we start a conversation, the first default language of communication we use is English, but if the other person is not familiar with English we try and translate our dialogue in a language that the person is familiar with. Similarly whenever we write a program or a document we write it in English by default. But what if someone who is not familiar with English wants to read your program or code? The simple solution is that we translate program or code into a language that the person is familiar with. And for this, we use a term called internationalization.&lt;br /&gt;
&lt;br /&gt;
:Internationalization is a way by which we can view an application in various languages without actually making changes to the code of the application. This saves us a lot of time and effort, as we don’t have to write or edit the same code or document in all the copies.&lt;br /&gt;
&lt;br /&gt;
:Internationalization has an acronym, rather more of a numeronym ,which is i18n where the number 18 represents the number of letters between the first and last letters in the word internationalization.&lt;br /&gt;
&lt;br /&gt;
== Aspects to consider in Internationalization ==&lt;br /&gt;
&lt;br /&gt;
:Now when we are to change our application according to a particular language or a region , we need to keep in mind numerous points that are important, implicit, particular or sensitive to that language or region. Like for example when we take a language into consideration for which our application needs to be translated, we need to consider the spoken and written aspects of that language. Also, there might be a case when we have the same language but it differs from one region to other. For this we need to keep in mind the typical change in the use of words, grammar and symbol for each region that uses the same language. Our application must also provide support for the varied writing conventions that differ from a language to another language or from one region to another.&lt;br /&gt;
&lt;br /&gt;
:Below are the examples of the points we need to keep in mind while we provide internationalization to our application :&lt;br /&gt;
&lt;br /&gt;
* Language :&lt;br /&gt;
&lt;br /&gt;
:Here the i18n support to an application needs to provide the character encoding keeping in mind the following points:&lt;br /&gt;
&lt;br /&gt;
#The written language differs. For example most of the languages like English, French, German follow a script that can have inputs from a standard keyboard. But there are other languages like Hindi, Marathi, Sanskrit that follow a script called Devnagri and this cannot be directly typed in from a standard keyboard. So if we have to provide support for these languages we need to support the translation of the characters used in these scripts.&lt;br /&gt;
#The way we write also differs and needs to included in our i18n support. For example most of the languages follow a left-right direction while writing but some languages like Urdu tend to follow a right-left direction.&lt;br /&gt;
#The numbering symbols also vary from language to language. So when we display or accept any text with numbers, we must have i18n to support this mapping.&lt;br /&gt;
#The languages also differ in the use of grammar and structure of the sentences.For example the grammar rules and structure formation in English is way different than the one followed by another language like Sanskrit.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Culture and Writing Conventions:&lt;br /&gt;
&lt;br /&gt;
:Even if the language with the same characters and grammar is used, the use of the language , the symbols , the way of writing and many other things change with change in the region.&lt;br /&gt;
:Following are some of the examples:&lt;br /&gt;
&lt;br /&gt;
#There are some cultures that have some regulations about having a middle name as father’s name but other cultures don’t necessary include the middle name.&lt;br /&gt;
#There might be cases when there are different names or terminologies used in different cultures for the same purpose. For example, to identify a citizen uniquely US has the system of SSN while India is in the process of implementing this by using the term as Aadhar number.&lt;br /&gt;
#Another example of difference in the writing convention can be taken as that of a postal code. Some countries have 6 digit postal codes while others have 5.&lt;br /&gt;
#There is a difference in the use of many other things like the currency(like INR,dollars,Euro) used, the symbols(€,$,₹) used , the units in which the weights , temperature are measured. Another example could be the use of lakhs , crores for mentioning any financial figures in some countries while others use millions, billions.&lt;br /&gt;
#There could also be a difference in the formats used for a same thing. For example the format of writing dates and times vary from one region to another.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* We also have to be careful that we cover all the sensitive topics and issues particular to a language or region.&lt;br /&gt;
&lt;br /&gt;
:Similarly there are many other factors that we need to take care of when we support internationalization for a particular language in a particular region.&lt;br /&gt;
&lt;br /&gt;
= Internationalization in Rails =&lt;br /&gt;
&lt;br /&gt;
:Internationalization support was extended from Rails version 2.2. So in order to internationalize a rails application, it has to be migrated :to Rails 2.2 or above. Every static string in the Rails framework — e.g. Active Record validation messages, time and date formats — have :been internationalized.&lt;br /&gt;
&lt;br /&gt;
:Following needs to be done in order to internationalize a rails application:&lt;br /&gt;
:#Ensure support for internationalization by migrating to appropriate version of rails if needed.&lt;br /&gt;
:#Tell rails where to find the appropriate translations files&lt;br /&gt;
:#Tell rails how to switch locales&lt;br /&gt;
&lt;br /&gt;
::YAML (.yml) or plain Ruby (.rb) files are used for storing translations.&lt;br /&gt;
&lt;br /&gt;
== History ==&lt;br /&gt;
&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100pt&amp;quot;| Ruby 2.2    || Internationalization support was extended from this version of Rails.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 2.3    || Additional feature for Localized Views was added in this version. The view files were rendered with an extension of the locale name.I18n#available_locales and I18n::SimpleBackend#available_locales is available to retrieve an array of available locales.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 3.0    || Some additional features were added to the I18n gem for speed improvements like default translations for attributes,automatic pull for translations on form submit, etc.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 3.1    || I18n namespace lookup support removed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Ways to configure Internationalization in Rails ==&lt;br /&gt;
&lt;br /&gt;
:We can set up a rails application to support internationalization in a number of ways. Below are the various ways to configure our rails application for internationalization.&lt;br /&gt;
&lt;br /&gt;
#'''Configure the I18n module:'''&amp;lt;br&amp;gt;Rails adds all .rb and .yml files from the config/locales directory to your translations load path, automatically. This is the default setting provided by the [https://github.com/svenfuchs/i18n I18n gem]. In order to override this setting we have to make changes in the application.rb files that have instructions on how to add locales from another directory and how to set a different default locale.&lt;br /&gt;
#'''Custom I18n Configuration Setup:'''&amp;lt;br&amp;gt;Optionally, the above code can be placed anywhere in the application preferably in initializers.&lt;br /&gt;
#'''Setting and passing locale:'''&amp;lt;br&amp;gt;The above two steps help setup a default locale throughout the application. But in case we have to provide our application in different languages, we can setup the application default locale in the application.rb and then set the locale using the application-controller.rb before_action. We can then pass the locale we want as a query param for example http://study.com/books?locale=es&lt;br /&gt;
#'''Setting the locale from the domain name:'''&amp;lt;br&amp;gt;Similar to option 3 but instead of passing the locale as a query param, the locale is a part of the domain name itself. Example http://study.es&lt;br /&gt;
::You can implement it like this in your ApplicationController before_action&lt;br /&gt;
#'''Setting the locale from the URL params:'''&amp;lt;br&amp;gt;&lt;br /&gt;
##This can be a tedious task as we have to pass the locale on each request. &lt;br /&gt;
##Rails provides us an alternative for &amp;quot;centralizing dynamic decisions about the URLs&amp;quot; in its ApplicationController#default_url_options and helper methods are dependent on it (by implementing/overriding this method). This will now automatically include the locale param in the query string&lt;br /&gt;
##We can also set the locale in the URL route. For example -http://study.com/es/books .This is achievable by using over-riding default_url_options. You just have to set up your routes with scoping option in routes.rb. &lt;br /&gt;
#'''Setting the locale from client supplied information:'''&amp;lt;br&amp;gt;This can be done in 3 ways&lt;br /&gt;
##Using the default locale of the client browser&lt;br /&gt;
##Using client location to select the locale&lt;br /&gt;
##Saving the users choice of locale as a part of user profile&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Internationalizing Rails application ==&lt;br /&gt;
&lt;br /&gt;
:After your application is prepared for internationalization, we need to use the feature in our application. &lt;br /&gt;
:This can be done in the following ways:&lt;br /&gt;
&lt;br /&gt;
1. '''Adding Translations:'''&lt;br /&gt;
:In order to internationalize rails code, replace the strings with calls to  the ‘t’ helper.&amp;lt;br&amp;gt;For example: &lt;br /&gt;
 class HelloWorld &lt;br /&gt;
  def sayHello&lt;br /&gt;
    puts t(:hello_world)&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;%=t :hello_world %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:The helper method t also catches missing translations and displays appropriate error message.&lt;br /&gt;
 &amp;lt;nowiki /&amp;gt;# config/locales/en.yml&lt;br /&gt;
 en: hello_world: Hello world!&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki /&amp;gt;# config/locales/es.yml&lt;br /&gt;
 es: hello_world: hola mundo&lt;br /&gt;
&lt;br /&gt;
2. '''Passing variables to translation:'''&lt;br /&gt;
:You can use variables in the translation messages and pass their values from the view.&lt;br /&gt;
 en:&lt;br /&gt;
 portal: &amp;quot;Mypack&amp;quot;&lt;br /&gt;
   university:&lt;br /&gt;
    ncsu:&lt;br /&gt;
    description: ! 'NCSU student information is accessed on %{portal_name}’ &lt;br /&gt;
&lt;br /&gt;
 t('.description', portal_name: t(‘portal’))&lt;br /&gt;
&lt;br /&gt;
3. '''Adding date/ time formats:'''&lt;br /&gt;
:OK! Now let's add a timestamp to the view, so we can demo the date/time localization feature as well. To localize the time format you pass the Time object to I18n.l or (preferably) use ‘l’ helper. You can pick a format by passing the :format option — by default the :default format is used.&lt;br /&gt;
:In the view file:&lt;br /&gt;
 &amp;lt;%= l Time.now, format: :short %&amp;gt;&lt;br /&gt;
:In the yml file:&lt;br /&gt;
  es:&lt;br /&gt;
   time:&lt;br /&gt;
     formats:&lt;br /&gt;
       short: &amp;quot; Son las %H&amp;quot;&lt;br /&gt;
&lt;br /&gt;
4. '''Inflection rules for locales other than english:'''&lt;br /&gt;
:Rails 4.0 provides a feature to define inflection rules (singularization and pluralization)  in config/initializers/inflections.rb. &lt;br /&gt;
&lt;br /&gt;
5. '''Localized views:'''&lt;br /&gt;
:For static websites available in different languages or for large static content, localized views is a useful feature. This feature enables having separate view file for different locales. For example for default locale we can have show.html.erb file while for Spanish we can have show.es.html.erb. Thus we don’t need to maintain long .yml files for each supported locale for long static pages.&lt;br /&gt;
&lt;br /&gt;
== Internationalization Features ==&lt;br /&gt;
&lt;br /&gt;
1. '''Using Different Backends:'''&lt;br /&gt;
:The i18n provides a [http://www.ruby-doc.org/gems/docs/s/synergy_russian-0.2.8/I18n/Backend/Simple.html simple backend] by default. We can change the backend to an active records backend or chain multiple backends as per the requirements of our application. I18n gem also provides cache, fallback and pluralization feature for the backends.&lt;br /&gt;
&lt;br /&gt;
2. '''Pluralization:'''&lt;br /&gt;
:Different languages have different rules for pluralization. Thus, the I18n API provides a flexible pluralization feature.&lt;br /&gt;
&lt;br /&gt;
3. '''Fallbacks:'''&lt;br /&gt;
:In case translation for a certain  locale is missing we can define fallback chain for the locales.&lt;br /&gt;
:For example we can define a fallback chain of the form &lt;br /&gt;
 :'en-CA' =&amp;gt; :'en-US', :'en-US' =&amp;gt; :en, :de =&amp;gt; :en &lt;br /&gt;
&lt;br /&gt;
:if the translation for en-CA is missing rails looks for en-US , if en-US is missing it then looks for en and so on.&lt;br /&gt;
&lt;br /&gt;
4. '''Cascading lookups:'''&lt;br /&gt;
:If a given key is not found, it is broken and a lookup is performed for the remaining portion of the key before finally falling back to the defaults.&lt;br /&gt;
&lt;br /&gt;
5. '''Translation symlinks:'''&lt;br /&gt;
:A key can be a value for another key.&lt;br /&gt;
:Example:&lt;br /&gt;
 person: ‘ash’&lt;br /&gt;
 student: :person&lt;br /&gt;
 employee: :person&lt;br /&gt;
&lt;br /&gt;
:Ash can be an employee or a student. Each key represents the same value.&lt;br /&gt;
&lt;br /&gt;
6. '''Translation procs:'''&lt;br /&gt;
:I18n gem allows writing translation logic in the translation lookup process.&lt;br /&gt;
:For example:&lt;br /&gt;
 :en&lt;br /&gt;
  	:addressing =&amp;gt; lambda { |values|&lt;br /&gt;
 		person=values[:person]&lt;br /&gt;
 		address=person.male? ?  “Sir” : “Madam”&lt;br /&gt;
 	“Hello, #{person.address}”&lt;br /&gt;
 &lt;br /&gt;
 t(:addressing , :person =&amp;gt; mary)&lt;/div&gt;</summary>
		<author><name>Srparadk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w18_bs&amp;diff=76118</id>
		<title>CSC/ECE 517 Fall 2013/ch1 1w18 bs</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w18_bs&amp;diff=76118"/>
		<updated>2013-09-16T21:02:19Z</updated>

		<summary type="html">&lt;p&gt;Srparadk: /* Internationalization Features */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Internationalization in Rails&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
:In general when we start a conversation, the first default language of communication we use is English, but if the other person is not familiar with English we try and translate our dialogue in a language that the person is familiar with. Similarly whenever we write a program or a document we write it in English by default. But what if someone who is not familiar with English wants to read your program or code? The simple solution is that we translate program or code into a language that the person is familiar with. And for this, we use a term called internationalization.&lt;br /&gt;
&lt;br /&gt;
:Internationalization is a way by which we can view an application in various languages without actually making changes to the code of the application. This saves us a lot of time and effort, as we don’t have to write or edit the same code or document in all the copies.&lt;br /&gt;
&lt;br /&gt;
:Internationalization has an acronym, rather more of a numeronym ,which is i18n where the number 18 represents the number of letters between the first and last letters in the word internationalization.&lt;br /&gt;
&lt;br /&gt;
== Aspects to consider in Internationalization ==&lt;br /&gt;
&lt;br /&gt;
:Now when we are to change our application according to a particular language or a region , we need to keep in mind numerous points that are important, implicit, particular or sensitive to that language or region. Like for example when we take a language into consideration for which our application needs to be translated, we need to consider the spoken and written aspects of that language. Also, there might be a case when we have the same language but it differs from one region to other. For this we need to keep in mind the typical change in the use of words, grammar and symbol for each region that uses the same language. Our application must also provide support for the varied writing conventions that differ from a language to another language or from one region to another.&lt;br /&gt;
&lt;br /&gt;
:Below are the examples of the points we need to keep in mind while we provide internationalization to our application :&lt;br /&gt;
&lt;br /&gt;
* Language :&lt;br /&gt;
&lt;br /&gt;
:Here the i18n support to an application needs to provide the character encoding keeping in mind the following points:&lt;br /&gt;
&lt;br /&gt;
#The written language differs. For example most of the languages like English, French, German follow a script that can have inputs from a standard keyboard. But there are other languages like Hindi, Marathi, Sanskrit that follow a script called Devnagri and this cannot be directly typed in from a standard keyboard. So if we have to provide support for these languages we need to support the translation of the characters used in these scripts.&lt;br /&gt;
#The way we write also differs and needs to included in our i18n support. For example most of the languages follow a left-right direction while writing but some languages like Urdu tend to follow a right-left direction.&lt;br /&gt;
#The numbering symbols also vary from language to language. So when we display or accept any text with numbers, we must have i18n to support this mapping.&lt;br /&gt;
#The languages also differ in the use of grammar and structure of the sentences.For example the grammar rules and structure formation in English is way different than the one followed by another language like Sanskrit.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Culture and Writing Conventions:&lt;br /&gt;
&lt;br /&gt;
:Even if the language with the same characters and grammar is used, the use of the language , the symbols , the way of writing and many other things change with change in the region.&lt;br /&gt;
:Following are some of the examples:&lt;br /&gt;
&lt;br /&gt;
#There are some cultures that have some regulations about having a middle name as father’s name but other cultures don’t necessary include the middle name.&lt;br /&gt;
#There might be cases when there are different names or terminologies used in different cultures for the same purpose. For example, to identify a citizen uniquely US has the system of SSN while India is in the process of implementing this by using the term as Aadhar number.&lt;br /&gt;
#Another example of difference in the writing convention can be taken as that of a postal code. Some countries have 6 digit postal codes while others have 5.&lt;br /&gt;
#There is a difference in the use of many other things like the currency(like INR,dollars,Euro) used, the symbols(€,$,₹) used , the units in which the weights , temperature are measured. Another example could be the use of lakhs , crores for mentioning any financial figures in some countries while others use millions, billions.&lt;br /&gt;
#There could also be a difference in the formats used for a same thing. For example the format of writing dates and times vary from one region to another.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* We also have to be careful that we cover all the sensitive topics and issues particular to a language or region.&lt;br /&gt;
&lt;br /&gt;
:Similarly there are many other factors that we need to take care of when we support internationalization for a particular language in a particular region.&lt;br /&gt;
&lt;br /&gt;
= Internationalization in Rails =&lt;br /&gt;
&lt;br /&gt;
:Internationalization support was extended from Rails version 2.2. So in order to internationalize a rails application, it has to be migrated :to Rails 2.2 or above. Every static string in the Rails framework — e.g. Active Record validation messages, time and date formats — have :been internationalized.&lt;br /&gt;
&lt;br /&gt;
:Following needs to be done in order to internationalize a rails application:&lt;br /&gt;
:#Ensure support for internationalization by migrating to appropriate version of rails if needed.&lt;br /&gt;
:#Tell rails where to find the appropriate translations files&lt;br /&gt;
:#Tell rails how to switch locales&lt;br /&gt;
&lt;br /&gt;
::YAML (.yml) or plain Ruby (.rb) files are used for storing translations.&lt;br /&gt;
&lt;br /&gt;
== History ==&lt;br /&gt;
&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100pt&amp;quot;| Ruby 2.2    || Internationalization support was extended from this version of Rails.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 2.3    || Additional feature for Localized Views was added in this version. The view files were rendered with an extension of the locale name.I18n#available_locales and I18n::SimpleBackend#available_locales is available to retrieve an array of available locales.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 3.0    || Some additional features were added to the I18n gem for speed improvements like default translations for attributes,automatic pull for translations on form submit, etc.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 3.1    || I18n namespace lookup support removed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Ways to configure Internationalization in Rails ==&lt;br /&gt;
&lt;br /&gt;
:We can set up a rails application to support internationalization in a number of ways. Below are the various ways to configure our rails application for internationalization.&lt;br /&gt;
&lt;br /&gt;
#'''Configure the I18n module:'''&amp;lt;br&amp;gt;Rails adds all .rb and .yml files from the config/locales directory to your translations load path, automatically. This is the default setting provided by the [https://github.com/svenfuchs/i18n I18n gem]. In order to override this setting we have to make changes in the application.rb files that have instructions on how to add locales from another directory and how to set a different default locale.&lt;br /&gt;
#'''Custom I18n Configuration Setup:'''&amp;lt;br&amp;gt;Optionally, the above code can be placed anywhere in the application preferably in initializers.&lt;br /&gt;
#'''Setting and passing locale:'''&amp;lt;br&amp;gt;The above two steps help setup a default locale throughout the application. But in case we have to provide our application in different languages, we can setup the application default locale in the application.rb and then set the locale using the application-controller.rb before_action. We can then pass the locale we want as a query param for example http://study.com/books?locale=es&lt;br /&gt;
#'''Setting the locale from the domain name:'''&amp;lt;br&amp;gt;Similar to option 3 but instead of passing the locale as a query param, the locale is a part of the domain name itself. Example http://study.es&lt;br /&gt;
::You can implement it like this in your ApplicationController before_action&lt;br /&gt;
#'''Setting the locale from the URL params:'''&amp;lt;br&amp;gt;&lt;br /&gt;
##This can be a tedious task as we have to pass the locale on each request. &lt;br /&gt;
##Rails provides us an alternative for &amp;quot;centralizing dynamic decisions about the URLs&amp;quot; in its ApplicationController#default_url_options and helper methods are dependent on it (by implementing/overriding this method). This will now automatically include the locale param in the query string&lt;br /&gt;
##We can also set the locale in the URL route. For example -http://study.com/es/books .This is achievable by using over-riding default_url_options. You just have to set up your routes with scoping option in routes.rb. &lt;br /&gt;
#'''Setting the locale from client supplied information:'''&amp;lt;br&amp;gt;This can be done in 3 ways&lt;br /&gt;
##Using the default locale of the client browser&lt;br /&gt;
##Using client location to select the locale&lt;br /&gt;
##Saving the users choice of locale as a part of user profile&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Internationalizing Rails application ==&lt;br /&gt;
&lt;br /&gt;
:After your application is prepared for internationalization, we need to use the feature in our application. &lt;br /&gt;
:This can be done in the following ways:&lt;br /&gt;
&lt;br /&gt;
1. '''Adding Translations:'''&lt;br /&gt;
:In order to internationalize rails code, replace the strings with calls to  the ‘t’ helper.&amp;lt;br&amp;gt;For example: &lt;br /&gt;
 class HelloWorld &lt;br /&gt;
  def sayHello&lt;br /&gt;
    puts t(:hello_world)&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;%=t :hello_world %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:The helper method t also catches missing translations and displays appropriate error message.&lt;br /&gt;
 &amp;lt;nowiki /&amp;gt;# config/locales/en.yml&lt;br /&gt;
 en: hello_world: Hello world!&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki /&amp;gt;# config/locales/es.yml&lt;br /&gt;
 es: hello_world: hola mundo&lt;br /&gt;
&lt;br /&gt;
2. '''Passing variables to translation:'''&lt;br /&gt;
:You can use variables in the translation messages and pass their values from the view.&lt;br /&gt;
 en:&lt;br /&gt;
 portal: &amp;quot;Mypack&amp;quot;&lt;br /&gt;
   university:&lt;br /&gt;
    ncsu:&lt;br /&gt;
    description: ! 'NCSU student information is accessed on %{portal_name}’ &lt;br /&gt;
&lt;br /&gt;
 t('.description', portal_name: t(‘portal’))&lt;br /&gt;
&lt;br /&gt;
3. '''Adding date/ time formats:'''&lt;br /&gt;
:OK! Now let's add a timestamp to the view, so we can demo the date/time localization feature as well. To localize the time format you pass the Time object to I18n.l or (preferably) use ‘l’ helper. You can pick a format by passing the :format option — by default the :default format is used.&lt;br /&gt;
:In the view file:&lt;br /&gt;
 &amp;lt;%= l Time.now, format: :short %&amp;gt;&lt;br /&gt;
:In the yml file:&lt;br /&gt;
  es:&lt;br /&gt;
   time:&lt;br /&gt;
     formats:&lt;br /&gt;
       short: &amp;quot; Son las %H&amp;quot;&lt;br /&gt;
&lt;br /&gt;
4. '''Inflection rules for locales other than english:'''&lt;br /&gt;
:Rails 4.0 provides a feature to define inflection rules (singularization and pluralization)  in config/initializers/inflections.rb. &lt;br /&gt;
&lt;br /&gt;
5. '''Localized views:'''&lt;br /&gt;
:For static websites available in different languages or for large static content, localized views is a useful feature. This feature enables having separate view file for different locales. For example for default locale we can have show.html.erb file while for Spanish we can have show.es.html.erb. Thus we don’t need to maintain long .yml files for each supported locale for long static pages.&lt;br /&gt;
&lt;br /&gt;
== Internationalization Features ==&lt;br /&gt;
&lt;br /&gt;
1. '''Using Different Backends:'''&lt;br /&gt;
:The i18n provides a [http://www.ruby-doc.org/gems/docs/s/synergy_russian-0.2.8/I18n/Backend/Simple.html simple backend] by default. We can change the backend to an active records backend or chain multiple backends as per the requirements of our application. I18n gem also provides cache, fallback and pluralization feature for the backends.&lt;br /&gt;
&lt;br /&gt;
2. '''Pluralization:'''&lt;br /&gt;
:Different languages have different rules for pluralization. Thus, the I18n API provides a flexible pluralization feature.&lt;br /&gt;
&lt;br /&gt;
3. '''Fallbacks:'''&lt;br /&gt;
:In case translation for a certain  locale is missing we can define fallback chain for the locales.&lt;br /&gt;
:For example we can define a fallback chain of the form &lt;br /&gt;
 :'en-CA' =&amp;gt; :'en-US', :'en-US' =&amp;gt; :en, :de =&amp;gt; :en &lt;br /&gt;
&lt;br /&gt;
:if the translation for en-CA is missing rails looks for en-US , if en-US is missing it then looks for en and so on.&lt;br /&gt;
&lt;br /&gt;
4. '''Cascading lookups:'''&lt;br /&gt;
:If a given key is not found, it is broken and a lookup is performed for the remaining portion of the key before finally falling back to the defaults.&lt;br /&gt;
&lt;br /&gt;
5. '''Translation symlinks:'''&lt;br /&gt;
:A key can be a value for another key.&lt;br /&gt;
:Example:&lt;br /&gt;
 person: ‘ash’&lt;br /&gt;
 student: :person&lt;br /&gt;
 employee: :person&lt;br /&gt;
&lt;br /&gt;
:Ash can be an employee or a student. Each key represents the same value.&lt;br /&gt;
&lt;br /&gt;
6. '''Translation procs:'''&lt;br /&gt;
:I18n gem allows writing translation logic in the translation lookup process.&lt;br /&gt;
:For example:&lt;br /&gt;
 :en&lt;br /&gt;
  	:addressing =&amp;gt; lambda { |values|&lt;br /&gt;
 		person=values[:person]&lt;br /&gt;
 		address=person.male? ?  “Sir” : “Madam”&lt;br /&gt;
 	“Hello, #{person.address}”&lt;br /&gt;
&lt;br /&gt;
t(:addressing , :person =&amp;gt; mary)&lt;/div&gt;</summary>
		<author><name>Srparadk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w18_bs&amp;diff=76115</id>
		<title>CSC/ECE 517 Fall 2013/ch1 1w18 bs</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w18_bs&amp;diff=76115"/>
		<updated>2013-09-16T21:00:09Z</updated>

		<summary type="html">&lt;p&gt;Srparadk: /* Internationalization Features */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Internationalization in Rails&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
:In general when we start a conversation, the first default language of communication we use is English, but if the other person is not familiar with English we try and translate our dialogue in a language that the person is familiar with. Similarly whenever we write a program or a document we write it in English by default. But what if someone who is not familiar with English wants to read your program or code? The simple solution is that we translate program or code into a language that the person is familiar with. And for this, we use a term called internationalization.&lt;br /&gt;
&lt;br /&gt;
:Internationalization is a way by which we can view an application in various languages without actually making changes to the code of the application. This saves us a lot of time and effort, as we don’t have to write or edit the same code or document in all the copies.&lt;br /&gt;
&lt;br /&gt;
:Internationalization has an acronym, rather more of a numeronym ,which is i18n where the number 18 represents the number of letters between the first and last letters in the word internationalization.&lt;br /&gt;
&lt;br /&gt;
== Aspects to consider in Internationalization ==&lt;br /&gt;
&lt;br /&gt;
:Now when we are to change our application according to a particular language or a region , we need to keep in mind numerous points that are important, implicit, particular or sensitive to that language or region. Like for example when we take a language into consideration for which our application needs to be translated, we need to consider the spoken and written aspects of that language. Also, there might be a case when we have the same language but it differs from one region to other. For this we need to keep in mind the typical change in the use of words, grammar and symbol for each region that uses the same language. Our application must also provide support for the varied writing conventions that differ from a language to another language or from one region to another.&lt;br /&gt;
&lt;br /&gt;
:Below are the examples of the points we need to keep in mind while we provide internationalization to our application :&lt;br /&gt;
&lt;br /&gt;
* Language :&lt;br /&gt;
&lt;br /&gt;
:Here the i18n support to an application needs to provide the character encoding keeping in mind the following points:&lt;br /&gt;
&lt;br /&gt;
#The written language differs. For example most of the languages like English, French, German follow a script that can have inputs from a standard keyboard. But there are other languages like Hindi, Marathi, Sanskrit that follow a script called Devnagri and this cannot be directly typed in from a standard keyboard. So if we have to provide support for these languages we need to support the translation of the characters used in these scripts.&lt;br /&gt;
#The way we write also differs and needs to included in our i18n support. For example most of the languages follow a left-right direction while writing but some languages like Urdu tend to follow a right-left direction.&lt;br /&gt;
#The numbering symbols also vary from language to language. So when we display or accept any text with numbers, we must have i18n to support this mapping.&lt;br /&gt;
#The languages also differ in the use of grammar and structure of the sentences.For example the grammar rules and structure formation in English is way different than the one followed by another language like Sanskrit.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Culture and Writing Conventions:&lt;br /&gt;
&lt;br /&gt;
:Even if the language with the same characters and grammar is used, the use of the language , the symbols , the way of writing and many other things change with change in the region.&lt;br /&gt;
:Following are some of the examples:&lt;br /&gt;
&lt;br /&gt;
#There are some cultures that have some regulations about having a middle name as father’s name but other cultures don’t necessary include the middle name.&lt;br /&gt;
#There might be cases when there are different names or terminologies used in different cultures for the same purpose. For example, to identify a citizen uniquely US has the system of SSN while India is in the process of implementing this by using the term as Aadhar number.&lt;br /&gt;
#Another example of difference in the writing convention can be taken as that of a postal code. Some countries have 6 digit postal codes while others have 5.&lt;br /&gt;
#There is a difference in the use of many other things like the currency(like INR,dollars,Euro) used, the symbols(€,$,₹) used , the units in which the weights , temperature are measured. Another example could be the use of lakhs , crores for mentioning any financial figures in some countries while others use millions, billions.&lt;br /&gt;
#There could also be a difference in the formats used for a same thing. For example the format of writing dates and times vary from one region to another.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* We also have to be careful that we cover all the sensitive topics and issues particular to a language or region.&lt;br /&gt;
&lt;br /&gt;
:Similarly there are many other factors that we need to take care of when we support internationalization for a particular language in a particular region.&lt;br /&gt;
&lt;br /&gt;
= Internationalization in Rails =&lt;br /&gt;
&lt;br /&gt;
:Internationalization support was extended from Rails version 2.2. So in order to internationalize a rails application, it has to be migrated :to Rails 2.2 or above. Every static string in the Rails framework — e.g. Active Record validation messages, time and date formats — have :been internationalized.&lt;br /&gt;
&lt;br /&gt;
:Following needs to be done in order to internationalize a rails application:&lt;br /&gt;
:#Ensure support for internationalization by migrating to appropriate version of rails if needed.&lt;br /&gt;
:#Tell rails where to find the appropriate translations files&lt;br /&gt;
:#Tell rails how to switch locales&lt;br /&gt;
&lt;br /&gt;
::YAML (.yml) or plain Ruby (.rb) files are used for storing translations.&lt;br /&gt;
&lt;br /&gt;
== History ==&lt;br /&gt;
&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100pt&amp;quot;| Ruby 2.2    || Internationalization support was extended from this version of Rails.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 2.3    || Additional feature for Localized Views was added in this version. The view files were rendered with an extension of the locale name.I18n#available_locales and I18n::SimpleBackend#available_locales is available to retrieve an array of available locales.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 3.0    || Some additional features were added to the I18n gem for speed improvements like default translations for attributes,automatic pull for translations on form submit, etc.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 3.1    || I18n namespace lookup support removed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Ways to configure Internationalization in Rails ==&lt;br /&gt;
&lt;br /&gt;
:We can set up a rails application to support internationalization in a number of ways. Below are the various ways to configure our rails application for internationalization.&lt;br /&gt;
&lt;br /&gt;
#'''Configure the I18n module:'''&amp;lt;br&amp;gt;Rails adds all .rb and .yml files from the config/locales directory to your translations load path, automatically. This is the default setting provided by the [https://github.com/svenfuchs/i18n I18n gem]. In order to override this setting we have to make changes in the application.rb files that have instructions on how to add locales from another directory and how to set a different default locale.&lt;br /&gt;
#'''Custom I18n Configuration Setup:'''&amp;lt;br&amp;gt;Optionally, the above code can be placed anywhere in the application preferably in initializers.&lt;br /&gt;
#'''Setting and passing locale:'''&amp;lt;br&amp;gt;The above two steps help setup a default locale throughout the application. But in case we have to provide our application in different languages, we can setup the application default locale in the application.rb and then set the locale using the application-controller.rb before_action. We can then pass the locale we want as a query param for example http://study.com/books?locale=es&lt;br /&gt;
#'''Setting the locale from the domain name:'''&amp;lt;br&amp;gt;Similar to option 3 but instead of passing the locale as a query param, the locale is a part of the domain name itself. Example http://study.es&lt;br /&gt;
::You can implement it like this in your ApplicationController before_action&lt;br /&gt;
#'''Setting the locale from the URL params:'''&amp;lt;br&amp;gt;&lt;br /&gt;
##This can be a tedious task as we have to pass the locale on each request. &lt;br /&gt;
##Rails provides us an alternative for &amp;quot;centralizing dynamic decisions about the URLs&amp;quot; in its ApplicationController#default_url_options and helper methods are dependent on it (by implementing/overriding this method). This will now automatically include the locale param in the query string&lt;br /&gt;
##We can also set the locale in the URL route. For example -http://study.com/es/books .This is achievable by using over-riding default_url_options. You just have to set up your routes with scoping option in routes.rb. &lt;br /&gt;
#'''Setting the locale from client supplied information:'''&amp;lt;br&amp;gt;This can be done in 3 ways&lt;br /&gt;
##Using the default locale of the client browser&lt;br /&gt;
##Using client location to select the locale&lt;br /&gt;
##Saving the users choice of locale as a part of user profile&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Internationalizing Rails application ==&lt;br /&gt;
&lt;br /&gt;
:After your application is prepared for internationalization, we need to use the feature in our application. &lt;br /&gt;
:This can be done in the following ways:&lt;br /&gt;
&lt;br /&gt;
1. '''Adding Translations:'''&lt;br /&gt;
:In order to internationalize rails code, replace the strings with calls to  the ‘t’ helper.&amp;lt;br&amp;gt;For example: &lt;br /&gt;
 class HelloWorld &lt;br /&gt;
  def sayHello&lt;br /&gt;
    puts t(:hello_world)&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;%=t :hello_world %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:The helper method t also catches missing translations and displays appropriate error message.&lt;br /&gt;
 &amp;lt;nowiki /&amp;gt;# config/locales/en.yml&lt;br /&gt;
 en: hello_world: Hello world!&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki /&amp;gt;# config/locales/es.yml&lt;br /&gt;
 es: hello_world: hola mundo&lt;br /&gt;
&lt;br /&gt;
2. '''Passing variables to translation:'''&lt;br /&gt;
:You can use variables in the translation messages and pass their values from the view.&lt;br /&gt;
 en:&lt;br /&gt;
 portal: &amp;quot;Mypack&amp;quot;&lt;br /&gt;
   university:&lt;br /&gt;
    ncsu:&lt;br /&gt;
    description: ! 'NCSU student information is accessed on %{portal_name}’ &lt;br /&gt;
&lt;br /&gt;
 t('.description', portal_name: t(‘portal’))&lt;br /&gt;
&lt;br /&gt;
3. '''Adding date/ time formats:'''&lt;br /&gt;
:OK! Now let's add a timestamp to the view, so we can demo the date/time localization feature as well. To localize the time format you pass the Time object to I18n.l or (preferably) use ‘l’ helper. You can pick a format by passing the :format option — by default the :default format is used.&lt;br /&gt;
:In the view file:&lt;br /&gt;
 &amp;lt;%= l Time.now, format: :short %&amp;gt;&lt;br /&gt;
:In the yml file:&lt;br /&gt;
  es:&lt;br /&gt;
   time:&lt;br /&gt;
     formats:&lt;br /&gt;
       short: &amp;quot; Son las %H&amp;quot;&lt;br /&gt;
&lt;br /&gt;
4. '''Inflection rules for locales other than english:'''&lt;br /&gt;
:Rails 4.0 provides a feature to define inflection rules (singularization and pluralization)  in config/initializers/inflections.rb. &lt;br /&gt;
&lt;br /&gt;
5. '''Localized views:'''&lt;br /&gt;
:For static websites available in different languages or for large static content, localized views is a useful feature. This feature enables having separate view file for different locales. For example for default locale we can have show.html.erb file while for Spanish we can have show.es.html.erb. Thus we don’t need to maintain long .yml files for each supported locale for long static pages.&lt;br /&gt;
&lt;br /&gt;
== Internationalization Features ==&lt;br /&gt;
&lt;br /&gt;
1. '''Using Different Backends:'''&lt;br /&gt;
:The i18n provides a [http://www.ruby-doc.org/gems/docs/s/synergy_russian-0.2.8/I18n/Backend/Simple.html simple backend] by default. We can change the backend to an active records backend or chain multiple backends as per the requirements of our application. I18n gem also provides cache, fallback and pluralization feature for the backends.&lt;br /&gt;
&lt;br /&gt;
2. '''Pluralization:'''&lt;br /&gt;
:Different languages have different rules for pluralization. Thus, the I18n API provides a flexible pluralization feature.&lt;br /&gt;
&lt;br /&gt;
3. '''Fallbacks:'''&lt;br /&gt;
:In case translation for a certain  locale is missing we can define fallback chain for the locales.&lt;br /&gt;
:For example we can define a fallback chain of the form &lt;br /&gt;
 :'en-CA' =&amp;gt; :'en-US', :'en-US' =&amp;gt; :en, :de =&amp;gt; :en &lt;br /&gt;
&lt;br /&gt;
:if the translation for en-CA is missing rails looks for en-US , if en-US is missing it then looks for en and so on.&lt;/div&gt;</summary>
		<author><name>Srparadk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w18_bs&amp;diff=76112</id>
		<title>CSC/ECE 517 Fall 2013/ch1 1w18 bs</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w18_bs&amp;diff=76112"/>
		<updated>2013-09-16T20:58:52Z</updated>

		<summary type="html">&lt;p&gt;Srparadk: /* Internationalizing Rails application */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Internationalization in Rails&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
:In general when we start a conversation, the first default language of communication we use is English, but if the other person is not familiar with English we try and translate our dialogue in a language that the person is familiar with. Similarly whenever we write a program or a document we write it in English by default. But what if someone who is not familiar with English wants to read your program or code? The simple solution is that we translate program or code into a language that the person is familiar with. And for this, we use a term called internationalization.&lt;br /&gt;
&lt;br /&gt;
:Internationalization is a way by which we can view an application in various languages without actually making changes to the code of the application. This saves us a lot of time and effort, as we don’t have to write or edit the same code or document in all the copies.&lt;br /&gt;
&lt;br /&gt;
:Internationalization has an acronym, rather more of a numeronym ,which is i18n where the number 18 represents the number of letters between the first and last letters in the word internationalization.&lt;br /&gt;
&lt;br /&gt;
== Aspects to consider in Internationalization ==&lt;br /&gt;
&lt;br /&gt;
:Now when we are to change our application according to a particular language or a region , we need to keep in mind numerous points that are important, implicit, particular or sensitive to that language or region. Like for example when we take a language into consideration for which our application needs to be translated, we need to consider the spoken and written aspects of that language. Also, there might be a case when we have the same language but it differs from one region to other. For this we need to keep in mind the typical change in the use of words, grammar and symbol for each region that uses the same language. Our application must also provide support for the varied writing conventions that differ from a language to another language or from one region to another.&lt;br /&gt;
&lt;br /&gt;
:Below are the examples of the points we need to keep in mind while we provide internationalization to our application :&lt;br /&gt;
&lt;br /&gt;
* Language :&lt;br /&gt;
&lt;br /&gt;
:Here the i18n support to an application needs to provide the character encoding keeping in mind the following points:&lt;br /&gt;
&lt;br /&gt;
#The written language differs. For example most of the languages like English, French, German follow a script that can have inputs from a standard keyboard. But there are other languages like Hindi, Marathi, Sanskrit that follow a script called Devnagri and this cannot be directly typed in from a standard keyboard. So if we have to provide support for these languages we need to support the translation of the characters used in these scripts.&lt;br /&gt;
#The way we write also differs and needs to included in our i18n support. For example most of the languages follow a left-right direction while writing but some languages like Urdu tend to follow a right-left direction.&lt;br /&gt;
#The numbering symbols also vary from language to language. So when we display or accept any text with numbers, we must have i18n to support this mapping.&lt;br /&gt;
#The languages also differ in the use of grammar and structure of the sentences.For example the grammar rules and structure formation in English is way different than the one followed by another language like Sanskrit.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Culture and Writing Conventions:&lt;br /&gt;
&lt;br /&gt;
:Even if the language with the same characters and grammar is used, the use of the language , the symbols , the way of writing and many other things change with change in the region.&lt;br /&gt;
:Following are some of the examples:&lt;br /&gt;
&lt;br /&gt;
#There are some cultures that have some regulations about having a middle name as father’s name but other cultures don’t necessary include the middle name.&lt;br /&gt;
#There might be cases when there are different names or terminologies used in different cultures for the same purpose. For example, to identify a citizen uniquely US has the system of SSN while India is in the process of implementing this by using the term as Aadhar number.&lt;br /&gt;
#Another example of difference in the writing convention can be taken as that of a postal code. Some countries have 6 digit postal codes while others have 5.&lt;br /&gt;
#There is a difference in the use of many other things like the currency(like INR,dollars,Euro) used, the symbols(€,$,₹) used , the units in which the weights , temperature are measured. Another example could be the use of lakhs , crores for mentioning any financial figures in some countries while others use millions, billions.&lt;br /&gt;
#There could also be a difference in the formats used for a same thing. For example the format of writing dates and times vary from one region to another.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* We also have to be careful that we cover all the sensitive topics and issues particular to a language or region.&lt;br /&gt;
&lt;br /&gt;
:Similarly there are many other factors that we need to take care of when we support internationalization for a particular language in a particular region.&lt;br /&gt;
&lt;br /&gt;
= Internationalization in Rails =&lt;br /&gt;
&lt;br /&gt;
:Internationalization support was extended from Rails version 2.2. So in order to internationalize a rails application, it has to be migrated :to Rails 2.2 or above. Every static string in the Rails framework — e.g. Active Record validation messages, time and date formats — have :been internationalized.&lt;br /&gt;
&lt;br /&gt;
:Following needs to be done in order to internationalize a rails application:&lt;br /&gt;
:#Ensure support for internationalization by migrating to appropriate version of rails if needed.&lt;br /&gt;
:#Tell rails where to find the appropriate translations files&lt;br /&gt;
:#Tell rails how to switch locales&lt;br /&gt;
&lt;br /&gt;
::YAML (.yml) or plain Ruby (.rb) files are used for storing translations.&lt;br /&gt;
&lt;br /&gt;
== History ==&lt;br /&gt;
&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100pt&amp;quot;| Ruby 2.2    || Internationalization support was extended from this version of Rails.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 2.3    || Additional feature for Localized Views was added in this version. The view files were rendered with an extension of the locale name.I18n#available_locales and I18n::SimpleBackend#available_locales is available to retrieve an array of available locales.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 3.0    || Some additional features were added to the I18n gem for speed improvements like default translations for attributes,automatic pull for translations on form submit, etc.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 3.1    || I18n namespace lookup support removed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Ways to configure Internationalization in Rails ==&lt;br /&gt;
&lt;br /&gt;
:We can set up a rails application to support internationalization in a number of ways. Below are the various ways to configure our rails application for internationalization.&lt;br /&gt;
&lt;br /&gt;
#'''Configure the I18n module:'''&amp;lt;br&amp;gt;Rails adds all .rb and .yml files from the config/locales directory to your translations load path, automatically. This is the default setting provided by the [https://github.com/svenfuchs/i18n I18n gem]. In order to override this setting we have to make changes in the application.rb files that have instructions on how to add locales from another directory and how to set a different default locale.&lt;br /&gt;
#'''Custom I18n Configuration Setup:'''&amp;lt;br&amp;gt;Optionally, the above code can be placed anywhere in the application preferably in initializers.&lt;br /&gt;
#'''Setting and passing locale:'''&amp;lt;br&amp;gt;The above two steps help setup a default locale throughout the application. But in case we have to provide our application in different languages, we can setup the application default locale in the application.rb and then set the locale using the application-controller.rb before_action. We can then pass the locale we want as a query param for example http://study.com/books?locale=es&lt;br /&gt;
#'''Setting the locale from the domain name:'''&amp;lt;br&amp;gt;Similar to option 3 but instead of passing the locale as a query param, the locale is a part of the domain name itself. Example http://study.es&lt;br /&gt;
::You can implement it like this in your ApplicationController before_action&lt;br /&gt;
#'''Setting the locale from the URL params:'''&amp;lt;br&amp;gt;&lt;br /&gt;
##This can be a tedious task as we have to pass the locale on each request. &lt;br /&gt;
##Rails provides us an alternative for &amp;quot;centralizing dynamic decisions about the URLs&amp;quot; in its ApplicationController#default_url_options and helper methods are dependent on it (by implementing/overriding this method). This will now automatically include the locale param in the query string&lt;br /&gt;
##We can also set the locale in the URL route. For example -http://study.com/es/books .This is achievable by using over-riding default_url_options. You just have to set up your routes with scoping option in routes.rb. &lt;br /&gt;
#'''Setting the locale from client supplied information:'''&amp;lt;br&amp;gt;This can be done in 3 ways&lt;br /&gt;
##Using the default locale of the client browser&lt;br /&gt;
##Using client location to select the locale&lt;br /&gt;
##Saving the users choice of locale as a part of user profile&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Internationalizing Rails application ==&lt;br /&gt;
&lt;br /&gt;
:After your application is prepared for internationalization, we need to use the feature in our application. &lt;br /&gt;
:This can be done in the following ways:&lt;br /&gt;
&lt;br /&gt;
1. '''Adding Translations:'''&lt;br /&gt;
:In order to internationalize rails code, replace the strings with calls to  the ‘t’ helper.&amp;lt;br&amp;gt;For example: &lt;br /&gt;
 class HelloWorld &lt;br /&gt;
  def sayHello&lt;br /&gt;
    puts t(:hello_world)&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;%=t :hello_world %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:The helper method t also catches missing translations and displays appropriate error message.&lt;br /&gt;
 &amp;lt;nowiki /&amp;gt;# config/locales/en.yml&lt;br /&gt;
 en: hello_world: Hello world!&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki /&amp;gt;# config/locales/es.yml&lt;br /&gt;
 es: hello_world: hola mundo&lt;br /&gt;
&lt;br /&gt;
2. '''Passing variables to translation:'''&lt;br /&gt;
:You can use variables in the translation messages and pass their values from the view.&lt;br /&gt;
 en:&lt;br /&gt;
 portal: &amp;quot;Mypack&amp;quot;&lt;br /&gt;
   university:&lt;br /&gt;
    ncsu:&lt;br /&gt;
    description: ! 'NCSU student information is accessed on %{portal_name}’ &lt;br /&gt;
&lt;br /&gt;
 t('.description', portal_name: t(‘portal’))&lt;br /&gt;
&lt;br /&gt;
3. '''Adding date/ time formats:'''&lt;br /&gt;
:OK! Now let's add a timestamp to the view, so we can demo the date/time localization feature as well. To localize the time format you pass the Time object to I18n.l or (preferably) use ‘l’ helper. You can pick a format by passing the :format option — by default the :default format is used.&lt;br /&gt;
:In the view file:&lt;br /&gt;
 &amp;lt;%= l Time.now, format: :short %&amp;gt;&lt;br /&gt;
:In the yml file:&lt;br /&gt;
  es:&lt;br /&gt;
   time:&lt;br /&gt;
     formats:&lt;br /&gt;
       short: &amp;quot; Son las %H&amp;quot;&lt;br /&gt;
&lt;br /&gt;
4. '''Inflection rules for locales other than english:'''&lt;br /&gt;
:Rails 4.0 provides a feature to define inflection rules (singularization and pluralization)  in config/initializers/inflections.rb. &lt;br /&gt;
&lt;br /&gt;
5. '''Localized views:'''&lt;br /&gt;
:For static websites available in different languages or for large static content, localized views is a useful feature. This feature enables having separate view file for different locales. For example for default locale we can have show.html.erb file while for Spanish we can have show.es.html.erb. Thus we don’t need to maintain long .yml files for each supported locale for long static pages.&lt;br /&gt;
&lt;br /&gt;
== Internationalization Features ==&lt;br /&gt;
&lt;br /&gt;
1. '''Using Different Backends:'''&lt;br /&gt;
:The i18n provides a [http://www.ruby-doc.org/gems/docs/s/synergy_russian-0.2.8/I18n/Backend/Simple.html simple backend] by default. We can change the backend to an active records backend or chain multiple backends as per the requirements of our application. I18n gem also provides cache, fallback and pluralization feature for the backends.&lt;br /&gt;
&lt;br /&gt;
2. '''Pluralization:'''&lt;br /&gt;
Different languages have different rules for pluralization. Thus, the I18n API provides a flexible pluralization feature.&lt;/div&gt;</summary>
		<author><name>Srparadk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w18_bs&amp;diff=76110</id>
		<title>CSC/ECE 517 Fall 2013/ch1 1w18 bs</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w18_bs&amp;diff=76110"/>
		<updated>2013-09-16T20:58:17Z</updated>

		<summary type="html">&lt;p&gt;Srparadk: /* Internationalization Features */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Internationalization in Rails&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
:In general when we start a conversation, the first default language of communication we use is English, but if the other person is not familiar with English we try and translate our dialogue in a language that the person is familiar with. Similarly whenever we write a program or a document we write it in English by default. But what if someone who is not familiar with English wants to read your program or code? The simple solution is that we translate program or code into a language that the person is familiar with. And for this, we use a term called internationalization.&lt;br /&gt;
&lt;br /&gt;
:Internationalization is a way by which we can view an application in various languages without actually making changes to the code of the application. This saves us a lot of time and effort, as we don’t have to write or edit the same code or document in all the copies.&lt;br /&gt;
&lt;br /&gt;
:Internationalization has an acronym, rather more of a numeronym ,which is i18n where the number 18 represents the number of letters between the first and last letters in the word internationalization.&lt;br /&gt;
&lt;br /&gt;
== Aspects to consider in Internationalization ==&lt;br /&gt;
&lt;br /&gt;
:Now when we are to change our application according to a particular language or a region , we need to keep in mind numerous points that are important, implicit, particular or sensitive to that language or region. Like for example when we take a language into consideration for which our application needs to be translated, we need to consider the spoken and written aspects of that language. Also, there might be a case when we have the same language but it differs from one region to other. For this we need to keep in mind the typical change in the use of words, grammar and symbol for each region that uses the same language. Our application must also provide support for the varied writing conventions that differ from a language to another language or from one region to another.&lt;br /&gt;
&lt;br /&gt;
:Below are the examples of the points we need to keep in mind while we provide internationalization to our application :&lt;br /&gt;
&lt;br /&gt;
* Language :&lt;br /&gt;
&lt;br /&gt;
:Here the i18n support to an application needs to provide the character encoding keeping in mind the following points:&lt;br /&gt;
&lt;br /&gt;
#The written language differs. For example most of the languages like English, French, German follow a script that can have inputs from a standard keyboard. But there are other languages like Hindi, Marathi, Sanskrit that follow a script called Devnagri and this cannot be directly typed in from a standard keyboard. So if we have to provide support for these languages we need to support the translation of the characters used in these scripts.&lt;br /&gt;
#The way we write also differs and needs to included in our i18n support. For example most of the languages follow a left-right direction while writing but some languages like Urdu tend to follow a right-left direction.&lt;br /&gt;
#The numbering symbols also vary from language to language. So when we display or accept any text with numbers, we must have i18n to support this mapping.&lt;br /&gt;
#The languages also differ in the use of grammar and structure of the sentences.For example the grammar rules and structure formation in English is way different than the one followed by another language like Sanskrit.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Culture and Writing Conventions:&lt;br /&gt;
&lt;br /&gt;
:Even if the language with the same characters and grammar is used, the use of the language , the symbols , the way of writing and many other things change with change in the region.&lt;br /&gt;
:Following are some of the examples:&lt;br /&gt;
&lt;br /&gt;
#There are some cultures that have some regulations about having a middle name as father’s name but other cultures don’t necessary include the middle name.&lt;br /&gt;
#There might be cases when there are different names or terminologies used in different cultures for the same purpose. For example, to identify a citizen uniquely US has the system of SSN while India is in the process of implementing this by using the term as Aadhar number.&lt;br /&gt;
#Another example of difference in the writing convention can be taken as that of a postal code. Some countries have 6 digit postal codes while others have 5.&lt;br /&gt;
#There is a difference in the use of many other things like the currency(like INR,dollars,Euro) used, the symbols(€,$,₹) used , the units in which the weights , temperature are measured. Another example could be the use of lakhs , crores for mentioning any financial figures in some countries while others use millions, billions.&lt;br /&gt;
#There could also be a difference in the formats used for a same thing. For example the format of writing dates and times vary from one region to another.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* We also have to be careful that we cover all the sensitive topics and issues particular to a language or region.&lt;br /&gt;
&lt;br /&gt;
:Similarly there are many other factors that we need to take care of when we support internationalization for a particular language in a particular region.&lt;br /&gt;
&lt;br /&gt;
= Internationalization in Rails =&lt;br /&gt;
&lt;br /&gt;
:Internationalization support was extended from Rails version 2.2. So in order to internationalize a rails application, it has to be migrated :to Rails 2.2 or above. Every static string in the Rails framework — e.g. Active Record validation messages, time and date formats — have :been internationalized.&lt;br /&gt;
&lt;br /&gt;
:Following needs to be done in order to internationalize a rails application:&lt;br /&gt;
:#Ensure support for internationalization by migrating to appropriate version of rails if needed.&lt;br /&gt;
:#Tell rails where to find the appropriate translations files&lt;br /&gt;
:#Tell rails how to switch locales&lt;br /&gt;
&lt;br /&gt;
::YAML (.yml) or plain Ruby (.rb) files are used for storing translations.&lt;br /&gt;
&lt;br /&gt;
== History ==&lt;br /&gt;
&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100pt&amp;quot;| Ruby 2.2    || Internationalization support was extended from this version of Rails.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 2.3    || Additional feature for Localized Views was added in this version. The view files were rendered with an extension of the locale name.I18n#available_locales and I18n::SimpleBackend#available_locales is available to retrieve an array of available locales.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 3.0    || Some additional features were added to the I18n gem for speed improvements like default translations for attributes,automatic pull for translations on form submit, etc.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 3.1    || I18n namespace lookup support removed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Ways to configure Internationalization in Rails ==&lt;br /&gt;
&lt;br /&gt;
:We can set up a rails application to support internationalization in a number of ways. Below are the various ways to configure our rails application for internationalization.&lt;br /&gt;
&lt;br /&gt;
#'''Configure the I18n module:'''&amp;lt;br&amp;gt;Rails adds all .rb and .yml files from the config/locales directory to your translations load path, automatically. This is the default setting provided by the [https://github.com/svenfuchs/i18n I18n gem]. In order to override this setting we have to make changes in the application.rb files that have instructions on how to add locales from another directory and how to set a different default locale.&lt;br /&gt;
#'''Custom I18n Configuration Setup:'''&amp;lt;br&amp;gt;Optionally, the above code can be placed anywhere in the application preferably in initializers.&lt;br /&gt;
#'''Setting and passing locale:'''&amp;lt;br&amp;gt;The above two steps help setup a default locale throughout the application. But in case we have to provide our application in different languages, we can setup the application default locale in the application.rb and then set the locale using the application-controller.rb before_action. We can then pass the locale we want as a query param for example http://study.com/books?locale=es&lt;br /&gt;
#'''Setting the locale from the domain name:'''&amp;lt;br&amp;gt;Similar to option 3 but instead of passing the locale as a query param, the locale is a part of the domain name itself. Example http://study.es&lt;br /&gt;
::You can implement it like this in your ApplicationController before_action&lt;br /&gt;
#'''Setting the locale from the URL params:'''&amp;lt;br&amp;gt;&lt;br /&gt;
##This can be a tedious task as we have to pass the locale on each request. &lt;br /&gt;
##Rails provides us an alternative for &amp;quot;centralizing dynamic decisions about the URLs&amp;quot; in its ApplicationController#default_url_options and helper methods are dependent on it (by implementing/overriding this method). This will now automatically include the locale param in the query string&lt;br /&gt;
##We can also set the locale in the URL route. For example -http://study.com/es/books .This is achievable by using over-riding default_url_options. You just have to set up your routes with scoping option in routes.rb. &lt;br /&gt;
#'''Setting the locale from client supplied information:'''&amp;lt;br&amp;gt;This can be done in 3 ways&lt;br /&gt;
##Using the default locale of the client browser&lt;br /&gt;
##Using client location to select the locale&lt;br /&gt;
##Saving the users choice of locale as a part of user profile&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Internationalizing Rails application ==&lt;br /&gt;
&lt;br /&gt;
:After your application is prepared for internationalization, we need to use the feature in our application. &lt;br /&gt;
:This can be done in the following ways:&lt;br /&gt;
&lt;br /&gt;
1.'''Adding Translations:'''&lt;br /&gt;
:In order to internationalize rails code, replace the strings with calls to  the ‘t’ helper.&amp;lt;br&amp;gt;For example: &lt;br /&gt;
 class HelloWorld &lt;br /&gt;
  def sayHello&lt;br /&gt;
    puts t(:hello_world)&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;%=t :hello_world %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:The helper method t also catches missing translations and displays appropriate error message.&lt;br /&gt;
 &amp;lt;nowiki /&amp;gt;# config/locales/en.yml&lt;br /&gt;
 en: hello_world: Hello world!&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki /&amp;gt;# config/locales/es.yml&lt;br /&gt;
 es: hello_world: hola mundo&lt;br /&gt;
&lt;br /&gt;
2.'''Passing variables to translation:'''&lt;br /&gt;
:You can use variables in the translation messages and pass their values from the view.&lt;br /&gt;
 en:&lt;br /&gt;
 portal: &amp;quot;Mypack&amp;quot;&lt;br /&gt;
   university:&lt;br /&gt;
    ncsu:&lt;br /&gt;
    description: ! 'NCSU student information is accessed on %{portal_name}’ &lt;br /&gt;
&lt;br /&gt;
 t('.description', portal_name: t(‘portal’))&lt;br /&gt;
&lt;br /&gt;
3.'''Adding date/ time formats:'''&lt;br /&gt;
:OK! Now let's add a timestamp to the view, so we can demo the date/time localization feature as well. To localize the time format you pass the Time object to I18n.l or (preferably) use ‘l’ helper. You can pick a format by passing the :format option — by default the :default format is used.&lt;br /&gt;
:In the view file:&lt;br /&gt;
 &amp;lt;%= l Time.now, format: :short %&amp;gt;&lt;br /&gt;
:In the yml file:&lt;br /&gt;
  es:&lt;br /&gt;
   time:&lt;br /&gt;
     formats:&lt;br /&gt;
       short: &amp;quot; Son las %H&amp;quot;&lt;br /&gt;
&lt;br /&gt;
4.'''Inflection rules for locales other than english:'''&lt;br /&gt;
:Rails 4.0 provides a feature to define inflection rules (singularization and pluralization)  in config/initializers/inflections.rb. &lt;br /&gt;
&lt;br /&gt;
5.'''Localized views:'''&lt;br /&gt;
:For static websites available in different languages or for large static content, localized views is a useful feature. This feature enables having separate view file for different locales. For example for default locale we can have show.html.erb file while for Spanish we can have show.es.html.erb. Thus we don’t need to maintain long .yml files for each supported locale for long static pages.&lt;br /&gt;
&lt;br /&gt;
== Internationalization Features ==&lt;br /&gt;
&lt;br /&gt;
1. '''Using Different Backends:'''&lt;br /&gt;
:The i18n provides a [http://www.ruby-doc.org/gems/docs/s/synergy_russian-0.2.8/I18n/Backend/Simple.html simple backend] by default. We can change the backend to an active records backend or chain multiple backends as per the requirements of our application. I18n gem also provides cache, fallback and pluralization feature for the backends.&lt;br /&gt;
&lt;br /&gt;
2. '''Pluralization:'''&lt;br /&gt;
Different languages have different rules for pluralization. Thus, the I18n API provides a flexible pluralization feature.&lt;/div&gt;</summary>
		<author><name>Srparadk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w18_bs&amp;diff=76109</id>
		<title>CSC/ECE 517 Fall 2013/ch1 1w18 bs</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w18_bs&amp;diff=76109"/>
		<updated>2013-09-16T20:57:17Z</updated>

		<summary type="html">&lt;p&gt;Srparadk: /* Internationalization Features */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Internationalization in Rails&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
:In general when we start a conversation, the first default language of communication we use is English, but if the other person is not familiar with English we try and translate our dialogue in a language that the person is familiar with. Similarly whenever we write a program or a document we write it in English by default. But what if someone who is not familiar with English wants to read your program or code? The simple solution is that we translate program or code into a language that the person is familiar with. And for this, we use a term called internationalization.&lt;br /&gt;
&lt;br /&gt;
:Internationalization is a way by which we can view an application in various languages without actually making changes to the code of the application. This saves us a lot of time and effort, as we don’t have to write or edit the same code or document in all the copies.&lt;br /&gt;
&lt;br /&gt;
:Internationalization has an acronym, rather more of a numeronym ,which is i18n where the number 18 represents the number of letters between the first and last letters in the word internationalization.&lt;br /&gt;
&lt;br /&gt;
== Aspects to consider in Internationalization ==&lt;br /&gt;
&lt;br /&gt;
:Now when we are to change our application according to a particular language or a region , we need to keep in mind numerous points that are important, implicit, particular or sensitive to that language or region. Like for example when we take a language into consideration for which our application needs to be translated, we need to consider the spoken and written aspects of that language. Also, there might be a case when we have the same language but it differs from one region to other. For this we need to keep in mind the typical change in the use of words, grammar and symbol for each region that uses the same language. Our application must also provide support for the varied writing conventions that differ from a language to another language or from one region to another.&lt;br /&gt;
&lt;br /&gt;
:Below are the examples of the points we need to keep in mind while we provide internationalization to our application :&lt;br /&gt;
&lt;br /&gt;
* Language :&lt;br /&gt;
&lt;br /&gt;
:Here the i18n support to an application needs to provide the character encoding keeping in mind the following points:&lt;br /&gt;
&lt;br /&gt;
#The written language differs. For example most of the languages like English, French, German follow a script that can have inputs from a standard keyboard. But there are other languages like Hindi, Marathi, Sanskrit that follow a script called Devnagri and this cannot be directly typed in from a standard keyboard. So if we have to provide support for these languages we need to support the translation of the characters used in these scripts.&lt;br /&gt;
#The way we write also differs and needs to included in our i18n support. For example most of the languages follow a left-right direction while writing but some languages like Urdu tend to follow a right-left direction.&lt;br /&gt;
#The numbering symbols also vary from language to language. So when we display or accept any text with numbers, we must have i18n to support this mapping.&lt;br /&gt;
#The languages also differ in the use of grammar and structure of the sentences.For example the grammar rules and structure formation in English is way different than the one followed by another language like Sanskrit.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Culture and Writing Conventions:&lt;br /&gt;
&lt;br /&gt;
:Even if the language with the same characters and grammar is used, the use of the language , the symbols , the way of writing and many other things change with change in the region.&lt;br /&gt;
:Following are some of the examples:&lt;br /&gt;
&lt;br /&gt;
#There are some cultures that have some regulations about having a middle name as father’s name but other cultures don’t necessary include the middle name.&lt;br /&gt;
#There might be cases when there are different names or terminologies used in different cultures for the same purpose. For example, to identify a citizen uniquely US has the system of SSN while India is in the process of implementing this by using the term as Aadhar number.&lt;br /&gt;
#Another example of difference in the writing convention can be taken as that of a postal code. Some countries have 6 digit postal codes while others have 5.&lt;br /&gt;
#There is a difference in the use of many other things like the currency(like INR,dollars,Euro) used, the symbols(€,$,₹) used , the units in which the weights , temperature are measured. Another example could be the use of lakhs , crores for mentioning any financial figures in some countries while others use millions, billions.&lt;br /&gt;
#There could also be a difference in the formats used for a same thing. For example the format of writing dates and times vary from one region to another.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* We also have to be careful that we cover all the sensitive topics and issues particular to a language or region.&lt;br /&gt;
&lt;br /&gt;
:Similarly there are many other factors that we need to take care of when we support internationalization for a particular language in a particular region.&lt;br /&gt;
&lt;br /&gt;
= Internationalization in Rails =&lt;br /&gt;
&lt;br /&gt;
:Internationalization support was extended from Rails version 2.2. So in order to internationalize a rails application, it has to be migrated :to Rails 2.2 or above. Every static string in the Rails framework — e.g. Active Record validation messages, time and date formats — have :been internationalized.&lt;br /&gt;
&lt;br /&gt;
:Following needs to be done in order to internationalize a rails application:&lt;br /&gt;
:#Ensure support for internationalization by migrating to appropriate version of rails if needed.&lt;br /&gt;
:#Tell rails where to find the appropriate translations files&lt;br /&gt;
:#Tell rails how to switch locales&lt;br /&gt;
&lt;br /&gt;
::YAML (.yml) or plain Ruby (.rb) files are used for storing translations.&lt;br /&gt;
&lt;br /&gt;
== History ==&lt;br /&gt;
&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100pt&amp;quot;| Ruby 2.2    || Internationalization support was extended from this version of Rails.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 2.3    || Additional feature for Localized Views was added in this version. The view files were rendered with an extension of the locale name.I18n#available_locales and I18n::SimpleBackend#available_locales is available to retrieve an array of available locales.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 3.0    || Some additional features were added to the I18n gem for speed improvements like default translations for attributes,automatic pull for translations on form submit, etc.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 3.1    || I18n namespace lookup support removed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Ways to configure Internationalization in Rails ==&lt;br /&gt;
&lt;br /&gt;
:We can set up a rails application to support internationalization in a number of ways. Below are the various ways to configure our rails application for internationalization.&lt;br /&gt;
&lt;br /&gt;
#'''Configure the I18n module:'''&amp;lt;br&amp;gt;Rails adds all .rb and .yml files from the config/locales directory to your translations load path, automatically. This is the default setting provided by the [https://github.com/svenfuchs/i18n I18n gem]. In order to override this setting we have to make changes in the application.rb files that have instructions on how to add locales from another directory and how to set a different default locale.&lt;br /&gt;
#'''Custom I18n Configuration Setup:'''&amp;lt;br&amp;gt;Optionally, the above code can be placed anywhere in the application preferably in initializers.&lt;br /&gt;
#'''Setting and passing locale:'''&amp;lt;br&amp;gt;The above two steps help setup a default locale throughout the application. But in case we have to provide our application in different languages, we can setup the application default locale in the application.rb and then set the locale using the application-controller.rb before_action. We can then pass the locale we want as a query param for example http://study.com/books?locale=es&lt;br /&gt;
#'''Setting the locale from the domain name:'''&amp;lt;br&amp;gt;Similar to option 3 but instead of passing the locale as a query param, the locale is a part of the domain name itself. Example http://study.es&lt;br /&gt;
::You can implement it like this in your ApplicationController before_action&lt;br /&gt;
#'''Setting the locale from the URL params:'''&amp;lt;br&amp;gt;&lt;br /&gt;
##This can be a tedious task as we have to pass the locale on each request. &lt;br /&gt;
##Rails provides us an alternative for &amp;quot;centralizing dynamic decisions about the URLs&amp;quot; in its ApplicationController#default_url_options and helper methods are dependent on it (by implementing/overriding this method). This will now automatically include the locale param in the query string&lt;br /&gt;
##We can also set the locale in the URL route. For example -http://study.com/es/books .This is achievable by using over-riding default_url_options. You just have to set up your routes with scoping option in routes.rb. &lt;br /&gt;
#'''Setting the locale from client supplied information:'''&amp;lt;br&amp;gt;This can be done in 3 ways&lt;br /&gt;
##Using the default locale of the client browser&lt;br /&gt;
##Using client location to select the locale&lt;br /&gt;
##Saving the users choice of locale as a part of user profile&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Internationalizing Rails application ==&lt;br /&gt;
&lt;br /&gt;
:After your application is prepared for internationalization, we need to use the feature in our application. &lt;br /&gt;
:This can be done in the following ways:&lt;br /&gt;
&lt;br /&gt;
1.'''Adding Translations:'''&lt;br /&gt;
:In order to internationalize rails code, replace the strings with calls to  the ‘t’ helper.&amp;lt;br&amp;gt;For example: &lt;br /&gt;
 class HelloWorld &lt;br /&gt;
  def sayHello&lt;br /&gt;
    puts t(:hello_world)&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;%=t :hello_world %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:The helper method t also catches missing translations and displays appropriate error message.&lt;br /&gt;
 &amp;lt;nowiki /&amp;gt;# config/locales/en.yml&lt;br /&gt;
 en: hello_world: Hello world!&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki /&amp;gt;# config/locales/es.yml&lt;br /&gt;
 es: hello_world: hola mundo&lt;br /&gt;
&lt;br /&gt;
2.'''Passing variables to translation:'''&lt;br /&gt;
:You can use variables in the translation messages and pass their values from the view.&lt;br /&gt;
 en:&lt;br /&gt;
 portal: &amp;quot;Mypack&amp;quot;&lt;br /&gt;
   university:&lt;br /&gt;
    ncsu:&lt;br /&gt;
    description: ! 'NCSU student information is accessed on %{portal_name}’ &lt;br /&gt;
&lt;br /&gt;
 t('.description', portal_name: t(‘portal’))&lt;br /&gt;
&lt;br /&gt;
3.'''Adding date/ time formats:'''&lt;br /&gt;
:OK! Now let's add a timestamp to the view, so we can demo the date/time localization feature as well. To localize the time format you pass the Time object to I18n.l or (preferably) use ‘l’ helper. You can pick a format by passing the :format option — by default the :default format is used.&lt;br /&gt;
:In the view file:&lt;br /&gt;
 &amp;lt;%= l Time.now, format: :short %&amp;gt;&lt;br /&gt;
:In the yml file:&lt;br /&gt;
  es:&lt;br /&gt;
   time:&lt;br /&gt;
     formats:&lt;br /&gt;
       short: &amp;quot; Son las %H&amp;quot;&lt;br /&gt;
&lt;br /&gt;
4.'''Inflection rules for locales other than english:'''&lt;br /&gt;
:Rails 4.0 provides a feature to define inflection rules (singularization and pluralization)  in config/initializers/inflections.rb. &lt;br /&gt;
&lt;br /&gt;
5.'''Localized views:'''&lt;br /&gt;
:For static websites available in different languages or for large static content, localized views is a useful feature. This feature enables having separate view file for different locales. For example for default locale we can have show.html.erb file while for Spanish we can have show.es.html.erb. Thus we don’t need to maintain long .yml files for each supported locale for long static pages.&lt;br /&gt;
&lt;br /&gt;
== Internationalization Features ==&lt;br /&gt;
&lt;br /&gt;
1.'''Using Different Backends:'''&lt;br /&gt;
:The i18n provides a [http://www.ruby-doc.org/gems/docs/s/synergy_russian-0.2.8/I18n/Backend/Simple.html simple backend] by default. We can change the backend to an active records backend or chain multiple backends as per the requirements of our application. I18n gem also provides cache, fallback and pluralization feature for the backends.&lt;/div&gt;</summary>
		<author><name>Srparadk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w18_bs&amp;diff=76107</id>
		<title>CSC/ECE 517 Fall 2013/ch1 1w18 bs</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w18_bs&amp;diff=76107"/>
		<updated>2013-09-16T20:56:32Z</updated>

		<summary type="html">&lt;p&gt;Srparadk: /* Internationalization Features */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Internationalization in Rails&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
:In general when we start a conversation, the first default language of communication we use is English, but if the other person is not familiar with English we try and translate our dialogue in a language that the person is familiar with. Similarly whenever we write a program or a document we write it in English by default. But what if someone who is not familiar with English wants to read your program or code? The simple solution is that we translate program or code into a language that the person is familiar with. And for this, we use a term called internationalization.&lt;br /&gt;
&lt;br /&gt;
:Internationalization is a way by which we can view an application in various languages without actually making changes to the code of the application. This saves us a lot of time and effort, as we don’t have to write or edit the same code or document in all the copies.&lt;br /&gt;
&lt;br /&gt;
:Internationalization has an acronym, rather more of a numeronym ,which is i18n where the number 18 represents the number of letters between the first and last letters in the word internationalization.&lt;br /&gt;
&lt;br /&gt;
== Aspects to consider in Internationalization ==&lt;br /&gt;
&lt;br /&gt;
:Now when we are to change our application according to a particular language or a region , we need to keep in mind numerous points that are important, implicit, particular or sensitive to that language or region. Like for example when we take a language into consideration for which our application needs to be translated, we need to consider the spoken and written aspects of that language. Also, there might be a case when we have the same language but it differs from one region to other. For this we need to keep in mind the typical change in the use of words, grammar and symbol for each region that uses the same language. Our application must also provide support for the varied writing conventions that differ from a language to another language or from one region to another.&lt;br /&gt;
&lt;br /&gt;
:Below are the examples of the points we need to keep in mind while we provide internationalization to our application :&lt;br /&gt;
&lt;br /&gt;
* Language :&lt;br /&gt;
&lt;br /&gt;
:Here the i18n support to an application needs to provide the character encoding keeping in mind the following points:&lt;br /&gt;
&lt;br /&gt;
#The written language differs. For example most of the languages like English, French, German follow a script that can have inputs from a standard keyboard. But there are other languages like Hindi, Marathi, Sanskrit that follow a script called Devnagri and this cannot be directly typed in from a standard keyboard. So if we have to provide support for these languages we need to support the translation of the characters used in these scripts.&lt;br /&gt;
#The way we write also differs and needs to included in our i18n support. For example most of the languages follow a left-right direction while writing but some languages like Urdu tend to follow a right-left direction.&lt;br /&gt;
#The numbering symbols also vary from language to language. So when we display or accept any text with numbers, we must have i18n to support this mapping.&lt;br /&gt;
#The languages also differ in the use of grammar and structure of the sentences.For example the grammar rules and structure formation in English is way different than the one followed by another language like Sanskrit.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Culture and Writing Conventions:&lt;br /&gt;
&lt;br /&gt;
:Even if the language with the same characters and grammar is used, the use of the language , the symbols , the way of writing and many other things change with change in the region.&lt;br /&gt;
:Following are some of the examples:&lt;br /&gt;
&lt;br /&gt;
#There are some cultures that have some regulations about having a middle name as father’s name but other cultures don’t necessary include the middle name.&lt;br /&gt;
#There might be cases when there are different names or terminologies used in different cultures for the same purpose. For example, to identify a citizen uniquely US has the system of SSN while India is in the process of implementing this by using the term as Aadhar number.&lt;br /&gt;
#Another example of difference in the writing convention can be taken as that of a postal code. Some countries have 6 digit postal codes while others have 5.&lt;br /&gt;
#There is a difference in the use of many other things like the currency(like INR,dollars,Euro) used, the symbols(€,$,₹) used , the units in which the weights , temperature are measured. Another example could be the use of lakhs , crores for mentioning any financial figures in some countries while others use millions, billions.&lt;br /&gt;
#There could also be a difference in the formats used for a same thing. For example the format of writing dates and times vary from one region to another.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* We also have to be careful that we cover all the sensitive topics and issues particular to a language or region.&lt;br /&gt;
&lt;br /&gt;
:Similarly there are many other factors that we need to take care of when we support internationalization for a particular language in a particular region.&lt;br /&gt;
&lt;br /&gt;
= Internationalization in Rails =&lt;br /&gt;
&lt;br /&gt;
:Internationalization support was extended from Rails version 2.2. So in order to internationalize a rails application, it has to be migrated :to Rails 2.2 or above. Every static string in the Rails framework — e.g. Active Record validation messages, time and date formats — have :been internationalized.&lt;br /&gt;
&lt;br /&gt;
:Following needs to be done in order to internationalize a rails application:&lt;br /&gt;
:#Ensure support for internationalization by migrating to appropriate version of rails if needed.&lt;br /&gt;
:#Tell rails where to find the appropriate translations files&lt;br /&gt;
:#Tell rails how to switch locales&lt;br /&gt;
&lt;br /&gt;
::YAML (.yml) or plain Ruby (.rb) files are used for storing translations.&lt;br /&gt;
&lt;br /&gt;
== History ==&lt;br /&gt;
&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100pt&amp;quot;| Ruby 2.2    || Internationalization support was extended from this version of Rails.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 2.3    || Additional feature for Localized Views was added in this version. The view files were rendered with an extension of the locale name.I18n#available_locales and I18n::SimpleBackend#available_locales is available to retrieve an array of available locales.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 3.0    || Some additional features were added to the I18n gem for speed improvements like default translations for attributes,automatic pull for translations on form submit, etc.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 3.1    || I18n namespace lookup support removed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Ways to configure Internationalization in Rails ==&lt;br /&gt;
&lt;br /&gt;
:We can set up a rails application to support internationalization in a number of ways. Below are the various ways to configure our rails application for internationalization.&lt;br /&gt;
&lt;br /&gt;
#'''Configure the I18n module:'''&amp;lt;br&amp;gt;Rails adds all .rb and .yml files from the config/locales directory to your translations load path, automatically. This is the default setting provided by the [https://github.com/svenfuchs/i18n I18n gem]. In order to override this setting we have to make changes in the application.rb files that have instructions on how to add locales from another directory and how to set a different default locale.&lt;br /&gt;
#'''Custom I18n Configuration Setup:'''&amp;lt;br&amp;gt;Optionally, the above code can be placed anywhere in the application preferably in initializers.&lt;br /&gt;
#'''Setting and passing locale:'''&amp;lt;br&amp;gt;The above two steps help setup a default locale throughout the application. But in case we have to provide our application in different languages, we can setup the application default locale in the application.rb and then set the locale using the application-controller.rb before_action. We can then pass the locale we want as a query param for example http://study.com/books?locale=es&lt;br /&gt;
#'''Setting the locale from the domain name:'''&amp;lt;br&amp;gt;Similar to option 3 but instead of passing the locale as a query param, the locale is a part of the domain name itself. Example http://study.es&lt;br /&gt;
::You can implement it like this in your ApplicationController before_action&lt;br /&gt;
#'''Setting the locale from the URL params:'''&amp;lt;br&amp;gt;&lt;br /&gt;
##This can be a tedious task as we have to pass the locale on each request. &lt;br /&gt;
##Rails provides us an alternative for &amp;quot;centralizing dynamic decisions about the URLs&amp;quot; in its ApplicationController#default_url_options and helper methods are dependent on it (by implementing/overriding this method). This will now automatically include the locale param in the query string&lt;br /&gt;
##We can also set the locale in the URL route. For example -http://study.com/es/books .This is achievable by using over-riding default_url_options. You just have to set up your routes with scoping option in routes.rb. &lt;br /&gt;
#'''Setting the locale from client supplied information:'''&amp;lt;br&amp;gt;This can be done in 3 ways&lt;br /&gt;
##Using the default locale of the client browser&lt;br /&gt;
##Using client location to select the locale&lt;br /&gt;
##Saving the users choice of locale as a part of user profile&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Internationalizing Rails application ==&lt;br /&gt;
&lt;br /&gt;
:After your application is prepared for internationalization, we need to use the feature in our application. &lt;br /&gt;
:This can be done in the following ways:&lt;br /&gt;
&lt;br /&gt;
1.'''Adding Translations:'''&lt;br /&gt;
:In order to internationalize rails code, replace the strings with calls to  the ‘t’ helper.&amp;lt;br&amp;gt;For example: &lt;br /&gt;
 class HelloWorld &lt;br /&gt;
  def sayHello&lt;br /&gt;
    puts t(:hello_world)&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;%=t :hello_world %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:The helper method t also catches missing translations and displays appropriate error message.&lt;br /&gt;
 &amp;lt;nowiki /&amp;gt;# config/locales/en.yml&lt;br /&gt;
 en: hello_world: Hello world!&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki /&amp;gt;# config/locales/es.yml&lt;br /&gt;
 es: hello_world: hola mundo&lt;br /&gt;
&lt;br /&gt;
2.'''Passing variables to translation:'''&lt;br /&gt;
:You can use variables in the translation messages and pass their values from the view.&lt;br /&gt;
 en:&lt;br /&gt;
 portal: &amp;quot;Mypack&amp;quot;&lt;br /&gt;
   university:&lt;br /&gt;
    ncsu:&lt;br /&gt;
    description: ! 'NCSU student information is accessed on %{portal_name}’ &lt;br /&gt;
&lt;br /&gt;
 t('.description', portal_name: t(‘portal’))&lt;br /&gt;
&lt;br /&gt;
3.'''Adding date/ time formats:'''&lt;br /&gt;
:OK! Now let's add a timestamp to the view, so we can demo the date/time localization feature as well. To localize the time format you pass the Time object to I18n.l or (preferably) use ‘l’ helper. You can pick a format by passing the :format option — by default the :default format is used.&lt;br /&gt;
:In the view file:&lt;br /&gt;
 &amp;lt;%= l Time.now, format: :short %&amp;gt;&lt;br /&gt;
:In the yml file:&lt;br /&gt;
  es:&lt;br /&gt;
   time:&lt;br /&gt;
     formats:&lt;br /&gt;
       short: &amp;quot; Son las %H&amp;quot;&lt;br /&gt;
&lt;br /&gt;
4.'''Inflection rules for locales other than english:'''&lt;br /&gt;
:Rails 4.0 provides a feature to define inflection rules (singularization and pluralization)  in config/initializers/inflections.rb. &lt;br /&gt;
&lt;br /&gt;
5.'''Localized views:'''&lt;br /&gt;
:For static websites available in different languages or for large static content, localized views is a useful feature. This feature enables having separate view file for different locales. For example for default locale we can have show.html.erb file while for Spanish we can have show.es.html.erb. Thus we don’t need to maintain long .yml files for each supported locale for long static pages.&lt;br /&gt;
&lt;br /&gt;
== Internationalization Features ==&lt;br /&gt;
&lt;br /&gt;
1.'''Using Different Backends:'''&lt;br /&gt;
:The i18n provides a simple [http://www.ruby-doc.org/gems/docs/s/synergy_russian-0.2.8/I18n/Backend/Simple.html backend] by default. We can change the backend to an active records backend or chain multiple backends as per the requirements of our application. I18n gem also provides cache, fallback and pluralization feature for the backends.&lt;/div&gt;</summary>
		<author><name>Srparadk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w18_bs&amp;diff=76100</id>
		<title>CSC/ECE 517 Fall 2013/ch1 1w18 bs</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w18_bs&amp;diff=76100"/>
		<updated>2013-09-16T20:54:47Z</updated>

		<summary type="html">&lt;p&gt;Srparadk: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Internationalization in Rails&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
:In general when we start a conversation, the first default language of communication we use is English, but if the other person is not familiar with English we try and translate our dialogue in a language that the person is familiar with. Similarly whenever we write a program or a document we write it in English by default. But what if someone who is not familiar with English wants to read your program or code? The simple solution is that we translate program or code into a language that the person is familiar with. And for this, we use a term called internationalization.&lt;br /&gt;
&lt;br /&gt;
:Internationalization is a way by which we can view an application in various languages without actually making changes to the code of the application. This saves us a lot of time and effort, as we don’t have to write or edit the same code or document in all the copies.&lt;br /&gt;
&lt;br /&gt;
:Internationalization has an acronym, rather more of a numeronym ,which is i18n where the number 18 represents the number of letters between the first and last letters in the word internationalization.&lt;br /&gt;
&lt;br /&gt;
== Aspects to consider in Internationalization ==&lt;br /&gt;
&lt;br /&gt;
:Now when we are to change our application according to a particular language or a region , we need to keep in mind numerous points that are important, implicit, particular or sensitive to that language or region. Like for example when we take a language into consideration for which our application needs to be translated, we need to consider the spoken and written aspects of that language. Also, there might be a case when we have the same language but it differs from one region to other. For this we need to keep in mind the typical change in the use of words, grammar and symbol for each region that uses the same language. Our application must also provide support for the varied writing conventions that differ from a language to another language or from one region to another.&lt;br /&gt;
&lt;br /&gt;
:Below are the examples of the points we need to keep in mind while we provide internationalization to our application :&lt;br /&gt;
&lt;br /&gt;
* Language :&lt;br /&gt;
&lt;br /&gt;
:Here the i18n support to an application needs to provide the character encoding keeping in mind the following points:&lt;br /&gt;
&lt;br /&gt;
#The written language differs. For example most of the languages like English, French, German follow a script that can have inputs from a standard keyboard. But there are other languages like Hindi, Marathi, Sanskrit that follow a script called Devnagri and this cannot be directly typed in from a standard keyboard. So if we have to provide support for these languages we need to support the translation of the characters used in these scripts.&lt;br /&gt;
#The way we write also differs and needs to included in our i18n support. For example most of the languages follow a left-right direction while writing but some languages like Urdu tend to follow a right-left direction.&lt;br /&gt;
#The numbering symbols also vary from language to language. So when we display or accept any text with numbers, we must have i18n to support this mapping.&lt;br /&gt;
#The languages also differ in the use of grammar and structure of the sentences.For example the grammar rules and structure formation in English is way different than the one followed by another language like Sanskrit.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Culture and Writing Conventions:&lt;br /&gt;
&lt;br /&gt;
:Even if the language with the same characters and grammar is used, the use of the language , the symbols , the way of writing and many other things change with change in the region.&lt;br /&gt;
:Following are some of the examples:&lt;br /&gt;
&lt;br /&gt;
#There are some cultures that have some regulations about having a middle name as father’s name but other cultures don’t necessary include the middle name.&lt;br /&gt;
#There might be cases when there are different names or terminologies used in different cultures for the same purpose. For example, to identify a citizen uniquely US has the system of SSN while India is in the process of implementing this by using the term as Aadhar number.&lt;br /&gt;
#Another example of difference in the writing convention can be taken as that of a postal code. Some countries have 6 digit postal codes while others have 5.&lt;br /&gt;
#There is a difference in the use of many other things like the currency(like INR,dollars,Euro) used, the symbols(€,$,₹) used , the units in which the weights , temperature are measured. Another example could be the use of lakhs , crores for mentioning any financial figures in some countries while others use millions, billions.&lt;br /&gt;
#There could also be a difference in the formats used for a same thing. For example the format of writing dates and times vary from one region to another.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* We also have to be careful that we cover all the sensitive topics and issues particular to a language or region.&lt;br /&gt;
&lt;br /&gt;
:Similarly there are many other factors that we need to take care of when we support internationalization for a particular language in a particular region.&lt;br /&gt;
&lt;br /&gt;
= Internationalization in Rails =&lt;br /&gt;
&lt;br /&gt;
:Internationalization support was extended from Rails version 2.2. So in order to internationalize a rails application, it has to be migrated :to Rails 2.2 or above. Every static string in the Rails framework — e.g. Active Record validation messages, time and date formats — have :been internationalized.&lt;br /&gt;
&lt;br /&gt;
:Following needs to be done in order to internationalize a rails application:&lt;br /&gt;
:#Ensure support for internationalization by migrating to appropriate version of rails if needed.&lt;br /&gt;
:#Tell rails where to find the appropriate translations files&lt;br /&gt;
:#Tell rails how to switch locales&lt;br /&gt;
&lt;br /&gt;
::YAML (.yml) or plain Ruby (.rb) files are used for storing translations.&lt;br /&gt;
&lt;br /&gt;
== History ==&lt;br /&gt;
&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100pt&amp;quot;| Ruby 2.2    || Internationalization support was extended from this version of Rails.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 2.3    || Additional feature for Localized Views was added in this version. The view files were rendered with an extension of the locale name.I18n#available_locales and I18n::SimpleBackend#available_locales is available to retrieve an array of available locales.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 3.0    || Some additional features were added to the I18n gem for speed improvements like default translations for attributes,automatic pull for translations on form submit, etc.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 3.1    || I18n namespace lookup support removed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Ways to configure Internationalization in Rails ==&lt;br /&gt;
&lt;br /&gt;
:We can set up a rails application to support internationalization in a number of ways. Below are the various ways to configure our rails application for internationalization.&lt;br /&gt;
&lt;br /&gt;
#'''Configure the I18n module:'''&amp;lt;br&amp;gt;Rails adds all .rb and .yml files from the config/locales directory to your translations load path, automatically. This is the default setting provided by the [https://github.com/svenfuchs/i18n I18n gem]. In order to override this setting we have to make changes in the application.rb files that have instructions on how to add locales from another directory and how to set a different default locale.&lt;br /&gt;
#'''Custom I18n Configuration Setup:'''&amp;lt;br&amp;gt;Optionally, the above code can be placed anywhere in the application preferably in initializers.&lt;br /&gt;
#'''Setting and passing locale:'''&amp;lt;br&amp;gt;The above two steps help setup a default locale throughout the application. But in case we have to provide our application in different languages, we can setup the application default locale in the application.rb and then set the locale using the application-controller.rb before_action. We can then pass the locale we want as a query param for example http://study.com/books?locale=es&lt;br /&gt;
#'''Setting the locale from the domain name:'''&amp;lt;br&amp;gt;Similar to option 3 but instead of passing the locale as a query param, the locale is a part of the domain name itself. Example http://study.es&lt;br /&gt;
::You can implement it like this in your ApplicationController before_action&lt;br /&gt;
#'''Setting the locale from the URL params:'''&amp;lt;br&amp;gt;&lt;br /&gt;
##This can be a tedious task as we have to pass the locale on each request. &lt;br /&gt;
##Rails provides us an alternative for &amp;quot;centralizing dynamic decisions about the URLs&amp;quot; in its ApplicationController#default_url_options and helper methods are dependent on it (by implementing/overriding this method). This will now automatically include the locale param in the query string&lt;br /&gt;
##We can also set the locale in the URL route. For example -http://study.com/es/books .This is achievable by using over-riding default_url_options. You just have to set up your routes with scoping option in routes.rb. &lt;br /&gt;
#'''Setting the locale from client supplied information:'''&amp;lt;br&amp;gt;This can be done in 3 ways&lt;br /&gt;
##Using the default locale of the client browser&lt;br /&gt;
##Using client location to select the locale&lt;br /&gt;
##Saving the users choice of locale as a part of user profile&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Internationalizing Rails application ==&lt;br /&gt;
&lt;br /&gt;
:After your application is prepared for internationalization, we need to use the feature in our application. &lt;br /&gt;
:This can be done in the following ways:&lt;br /&gt;
&lt;br /&gt;
1.'''Adding Translations:'''&lt;br /&gt;
:In order to internationalize rails code, replace the strings with calls to  the ‘t’ helper.&amp;lt;br&amp;gt;For example: &lt;br /&gt;
 class HelloWorld &lt;br /&gt;
  def sayHello&lt;br /&gt;
    puts t(:hello_world)&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;%=t :hello_world %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:The helper method t also catches missing translations and displays appropriate error message.&lt;br /&gt;
 &amp;lt;nowiki /&amp;gt;# config/locales/en.yml&lt;br /&gt;
 en: hello_world: Hello world!&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki /&amp;gt;# config/locales/es.yml&lt;br /&gt;
 es: hello_world: hola mundo&lt;br /&gt;
&lt;br /&gt;
2.'''Passing variables to translation:'''&lt;br /&gt;
:You can use variables in the translation messages and pass their values from the view.&lt;br /&gt;
 en:&lt;br /&gt;
 portal: &amp;quot;Mypack&amp;quot;&lt;br /&gt;
   university:&lt;br /&gt;
    ncsu:&lt;br /&gt;
    description: ! 'NCSU student information is accessed on %{portal_name}’ &lt;br /&gt;
&lt;br /&gt;
 t('.description', portal_name: t(‘portal’))&lt;br /&gt;
&lt;br /&gt;
3.'''Adding date/ time formats:'''&lt;br /&gt;
:OK! Now let's add a timestamp to the view, so we can demo the date/time localization feature as well. To localize the time format you pass the Time object to I18n.l or (preferably) use ‘l’ helper. You can pick a format by passing the :format option — by default the :default format is used.&lt;br /&gt;
:In the view file:&lt;br /&gt;
 &amp;lt;%= l Time.now, format: :short %&amp;gt;&lt;br /&gt;
:In the yml file:&lt;br /&gt;
  es:&lt;br /&gt;
   time:&lt;br /&gt;
     formats:&lt;br /&gt;
       short: &amp;quot; Son las %H&amp;quot;&lt;br /&gt;
&lt;br /&gt;
4.'''Inflection rules for locales other than english:'''&lt;br /&gt;
:Rails 4.0 provides a feature to define inflection rules (singularization and pluralization)  in config/initializers/inflections.rb. &lt;br /&gt;
&lt;br /&gt;
5.'''Localized views:'''&lt;br /&gt;
:For static websites available in different languages or for large static content, localized views is a useful feature. This feature enables having separate view file for different locales. For example for default locale we can have show.html.erb file while for Spanish we can have show.es.html.erb. Thus we don’t need to maintain long .yml files for each supported locale for long static pages.&lt;br /&gt;
&lt;br /&gt;
== Internationalization Features ==&lt;/div&gt;</summary>
		<author><name>Srparadk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w18_bs&amp;diff=76087</id>
		<title>CSC/ECE 517 Fall 2013/ch1 1w18 bs</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w18_bs&amp;diff=76087"/>
		<updated>2013-09-16T20:45:40Z</updated>

		<summary type="html">&lt;p&gt;Srparadk: /* Internationalizing Rails application */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Internationalization in Rails&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
:In general when we start a conversation, the first default language of communication we use is English, but if the other person is not familiar with English we try and translate our dialogue in a language that the person is familiar with. Similarly whenever we write a program or a document we write it in English by default. But what if someone who is not familiar with English wants to read your program or code? The simple solution is that we translate program or code into a language that the person is familiar with. And for this, we use a term called internationalization.&lt;br /&gt;
&lt;br /&gt;
:Internationalization is a way by which we can view an application in various languages without actually making changes to the code of the application. This saves us a lot of time and effort, as we don’t have to write or edit the same code or document in all the copies.&lt;br /&gt;
&lt;br /&gt;
:Internationalization has an acronym, rather more of a numeronym ,which is i18n where the number 18 represents the number of letters between the first and last letters in the word internationalization.&lt;br /&gt;
&lt;br /&gt;
== Aspects to consider in Internationalization ==&lt;br /&gt;
&lt;br /&gt;
:Now when we are to change our application according to a particular language or a region , we need to keep in mind numerous points that are important, implicit, particular or sensitive to that language or region. Like for example when we take a language into consideration for which our application needs to be translated, we need to consider the spoken and written aspects of that language. Also, there might be a case when we have the same language but it differs from one region to other. For this we need to keep in mind the typical change in the use of words, grammar and symbol for each region that uses the same language. Our application must also provide support for the varied writing conventions that differ from a language to another language or from one region to another.&lt;br /&gt;
&lt;br /&gt;
:Below are the examples of the points we need to keep in mind while we provide internationalization to our application :&lt;br /&gt;
&lt;br /&gt;
* Language :&lt;br /&gt;
&lt;br /&gt;
:Here the i18n support to an application needs to provide the character encoding keeping in mind the following points:&lt;br /&gt;
&lt;br /&gt;
#The written language differs. For example most of the languages like English, French, German follow a script that can have inputs from a standard keyboard. But there are other languages like Hindi, Marathi, Sanskrit that follow a script called Devnagri and this cannot be directly typed in from a standard keyboard. So if we have to provide support for these languages we need to support the translation of the characters used in these scripts.&lt;br /&gt;
#The way we write also differs and needs to included in our i18n support. For example most of the languages follow a left-right direction while writing but some languages like Urdu tend to follow a right-left direction.&lt;br /&gt;
#The numbering symbols also vary from language to language. So when we display or accept any text with numbers, we must have i18n to support this mapping.&lt;br /&gt;
#The languages also differ in the use of grammar and structure of the sentences.For example the grammar rules and structure formation in English is way different than the one followed by another language like Sanskrit.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Culture and Writing Conventions:&lt;br /&gt;
&lt;br /&gt;
:Even if the language with the same characters and grammar is used, the use of the language , the symbols , the way of writing and many other things change with change in the region.&lt;br /&gt;
:Following are some of the examples:&lt;br /&gt;
&lt;br /&gt;
#There are some cultures that have some regulations about having a middle name as father’s name but other cultures don’t necessary include the middle name.&lt;br /&gt;
#There might be cases when there are different names or terminologies used in different cultures for the same purpose. For example, to identify a citizen uniquely US has the system of SSN while India is in the process of implementing this by using the term as Aadhar number.&lt;br /&gt;
#Another example of difference in the writing convention can be taken as that of a postal code. Some countries have 6 digit postal codes while others have 5.&lt;br /&gt;
#There is a difference in the use of many other things like the currency(like INR,dollars,Euro) used, the symbols(€,$,₹) used , the units in which the weights , temperature are measured. Another example could be the use of lakhs , crores for mentioning any financial figures in some countries while others use millions, billions.&lt;br /&gt;
#There could also be a difference in the formats used for a same thing. For example the format of writing dates and times vary from one region to another.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* We also have to be careful that we cover all the sensitive topics and issues particular to a language or region.&lt;br /&gt;
&lt;br /&gt;
:Similarly there are many other factors that we need to take care of when we support internationalization for a particular language in a particular region.&lt;br /&gt;
&lt;br /&gt;
= Internationalization in Rails =&lt;br /&gt;
&lt;br /&gt;
:Internationalization support was extended from Rails version 2.2. So in order to internationalize a rails application, it has to be migrated :to Rails 2.2 or above. Every static string in the Rails framework — e.g. Active Record validation messages, time and date formats — have :been internationalized.&lt;br /&gt;
&lt;br /&gt;
:Following needs to be done in order to internationalize a rails application:&lt;br /&gt;
:#Ensure support for internationalization by migrating to appropriate version of rails if needed.&lt;br /&gt;
:#Tell rails where to find the appropriate translations files&lt;br /&gt;
:#Tell rails how to switch locales&lt;br /&gt;
&lt;br /&gt;
::YAML (.yml) or plain Ruby (.rb) files are used for storing translations.&lt;br /&gt;
&lt;br /&gt;
== History ==&lt;br /&gt;
&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100pt&amp;quot;| Ruby 2.2    || Internationalization support was extended from this version of Rails.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 2.3    || Additional feature for Localized Views was added in this version. The view files were rendered with an extension of the locale name.I18n#available_locales and I18n::SimpleBackend#available_locales is available to retrieve an array of available locales.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 3.0    || Some additional features were added to the I18n gem for speed improvements like default translations for attributes,automatic pull for translations on form submit, etc.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 3.1    || I18n namespace lookup support removed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Ways to configure Internationalization in Rails ==&lt;br /&gt;
&lt;br /&gt;
:We can set up a rails application to support internationalization in a number of ways. Below are the various ways to configure our rails application for internationalization.&lt;br /&gt;
&lt;br /&gt;
#'''Configure the I18n module:'''&amp;lt;br&amp;gt;Rails adds all .rb and .yml files from the config/locales directory to your translations load path, automatically. This is the default setting provided by the [https://github.com/svenfuchs/i18n I18n gem]. In order to override this setting we have to make changes in the application.rb files that have instructions on how to add locales from another directory and how to set a different default locale.&lt;br /&gt;
#'''Custom I18n Configuration Setup:'''&amp;lt;br&amp;gt;Optionally, the above code can be placed anywhere in the application preferably in initializers.&lt;br /&gt;
#'''Setting and passing locale:'''&amp;lt;br&amp;gt;The above two steps help setup a default locale throughout the application. But in case we have to provide our application in different languages, we can setup the application default locale in the application.rb and then set the locale using the application-controller.rb before_action. We can then pass the locale we want as a query param for example http://study.com/books?locale=es&lt;br /&gt;
#'''Setting the locale from the domain name:'''&amp;lt;br&amp;gt;Similar to option 3 but instead of passing the locale as a query param, the locale is a part of the domain name itself. Example http://study.es&lt;br /&gt;
::You can implement it like this in your ApplicationController before_action&lt;br /&gt;
#'''Setting the locale from the URL params:'''&amp;lt;br&amp;gt;&lt;br /&gt;
##This can be a tedious task as we have to pass the locale on each request. &lt;br /&gt;
##Rails provides us an alternative for &amp;quot;centralizing dynamic decisions about the URLs&amp;quot; in its ApplicationController#default_url_options and helper methods are dependent on it (by implementing/overriding this method). This will now automatically include the locale param in the query string&lt;br /&gt;
##We can also set the locale in the URL route. For example -http://study.com/es/books .This is achievable by using over-riding default_url_options. You just have to set up your routes with scoping option in routes.rb. &lt;br /&gt;
#'''Setting the locale from client supplied information:'''&amp;lt;br&amp;gt;This can be done in 3 ways&lt;br /&gt;
##Using the default locale of the client browser&lt;br /&gt;
##Using client location to select the locale&lt;br /&gt;
##Saving the users choice of locale as a part of user profile&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Internationalizing Rails application ==&lt;br /&gt;
&lt;br /&gt;
:After your application is prepared for internationalization, we need to use the feature in our application. &lt;br /&gt;
:This can be done in the following ways:&lt;br /&gt;
&lt;br /&gt;
1.'''Adding Translations:'''&lt;br /&gt;
:In order to internationalize rails code, replace the strings with calls to  the ‘t’ helper.&amp;lt;br&amp;gt;For example: &lt;br /&gt;
 class HelloWorld &lt;br /&gt;
  def sayHello&lt;br /&gt;
    puts t(:hello_world)&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;%=t :hello_world %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:The helper method t also catches missing translations and displays appropriate error message.&lt;br /&gt;
 &amp;lt;nowiki /&amp;gt;# config/locales/en.yml&lt;br /&gt;
 en: hello_world: Hello world!&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki /&amp;gt;# config/locales/es.yml&lt;br /&gt;
 es: hello_world: hola mundo&lt;br /&gt;
&lt;br /&gt;
2.'''Passing variables to translation:'''&lt;br /&gt;
:You can use variables in the translation messages and pass their values from the view.&lt;br /&gt;
 en:&lt;br /&gt;
 portal: &amp;quot;Mypack&amp;quot;&lt;br /&gt;
   university:&lt;br /&gt;
    ncsu:&lt;br /&gt;
    description: ! 'NCSU student information is accessed on %{portal_name}’ &lt;br /&gt;
&lt;br /&gt;
 t('.description', portal_name: t(‘portal’))&lt;br /&gt;
&lt;br /&gt;
3.'''Adding date/ time formats:'''&lt;br /&gt;
:OK! Now let's add a timestamp to the view, so we can demo the date/time localization feature as well. To localize the time format you pass the Time object to I18n.l or (preferably) use ‘l’ helper. You can pick a format by passing the :format option — by default the :default format is used.&lt;br /&gt;
:In the view file:&lt;br /&gt;
 &amp;lt;%= l Time.now, format: :short %&amp;gt;&lt;br /&gt;
:In the yml file:&lt;br /&gt;
  es:&lt;br /&gt;
   time:&lt;br /&gt;
     formats:&lt;br /&gt;
       short: &amp;quot; Son las %H&amp;quot;&lt;br /&gt;
&lt;br /&gt;
4.'''Inflection rules for locales other than english:'''&lt;br /&gt;
:Rails 4.0 provides a feature to define inflection rules (singularization and pluralization)  in config/initializers/inflections.rb. &lt;br /&gt;
&lt;br /&gt;
5.'''Localized views:'''&lt;br /&gt;
:For static websites available in different languages or for large static content, localized views is a useful feature. This feature enables having separate view file for different locales. For example for default locale we can have show.html.erb file while for Spanish we can have show.es.html.erb. Thus we don’t need to maintain long .yml files for each supported locale for long static pages.&lt;/div&gt;</summary>
		<author><name>Srparadk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w18_bs&amp;diff=76086</id>
		<title>CSC/ECE 517 Fall 2013/ch1 1w18 bs</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w18_bs&amp;diff=76086"/>
		<updated>2013-09-16T20:44:59Z</updated>

		<summary type="html">&lt;p&gt;Srparadk: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Internationalization in Rails&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
:In general when we start a conversation, the first default language of communication we use is English, but if the other person is not familiar with English we try and translate our dialogue in a language that the person is familiar with. Similarly whenever we write a program or a document we write it in English by default. But what if someone who is not familiar with English wants to read your program or code? The simple solution is that we translate program or code into a language that the person is familiar with. And for this, we use a term called internationalization.&lt;br /&gt;
&lt;br /&gt;
:Internationalization is a way by which we can view an application in various languages without actually making changes to the code of the application. This saves us a lot of time and effort, as we don’t have to write or edit the same code or document in all the copies.&lt;br /&gt;
&lt;br /&gt;
:Internationalization has an acronym, rather more of a numeronym ,which is i18n where the number 18 represents the number of letters between the first and last letters in the word internationalization.&lt;br /&gt;
&lt;br /&gt;
== Aspects to consider in Internationalization ==&lt;br /&gt;
&lt;br /&gt;
:Now when we are to change our application according to a particular language or a region , we need to keep in mind numerous points that are important, implicit, particular or sensitive to that language or region. Like for example when we take a language into consideration for which our application needs to be translated, we need to consider the spoken and written aspects of that language. Also, there might be a case when we have the same language but it differs from one region to other. For this we need to keep in mind the typical change in the use of words, grammar and symbol for each region that uses the same language. Our application must also provide support for the varied writing conventions that differ from a language to another language or from one region to another.&lt;br /&gt;
&lt;br /&gt;
:Below are the examples of the points we need to keep in mind while we provide internationalization to our application :&lt;br /&gt;
&lt;br /&gt;
* Language :&lt;br /&gt;
&lt;br /&gt;
:Here the i18n support to an application needs to provide the character encoding keeping in mind the following points:&lt;br /&gt;
&lt;br /&gt;
#The written language differs. For example most of the languages like English, French, German follow a script that can have inputs from a standard keyboard. But there are other languages like Hindi, Marathi, Sanskrit that follow a script called Devnagri and this cannot be directly typed in from a standard keyboard. So if we have to provide support for these languages we need to support the translation of the characters used in these scripts.&lt;br /&gt;
#The way we write also differs and needs to included in our i18n support. For example most of the languages follow a left-right direction while writing but some languages like Urdu tend to follow a right-left direction.&lt;br /&gt;
#The numbering symbols also vary from language to language. So when we display or accept any text with numbers, we must have i18n to support this mapping.&lt;br /&gt;
#The languages also differ in the use of grammar and structure of the sentences.For example the grammar rules and structure formation in English is way different than the one followed by another language like Sanskrit.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Culture and Writing Conventions:&lt;br /&gt;
&lt;br /&gt;
:Even if the language with the same characters and grammar is used, the use of the language , the symbols , the way of writing and many other things change with change in the region.&lt;br /&gt;
:Following are some of the examples:&lt;br /&gt;
&lt;br /&gt;
#There are some cultures that have some regulations about having a middle name as father’s name but other cultures don’t necessary include the middle name.&lt;br /&gt;
#There might be cases when there are different names or terminologies used in different cultures for the same purpose. For example, to identify a citizen uniquely US has the system of SSN while India is in the process of implementing this by using the term as Aadhar number.&lt;br /&gt;
#Another example of difference in the writing convention can be taken as that of a postal code. Some countries have 6 digit postal codes while others have 5.&lt;br /&gt;
#There is a difference in the use of many other things like the currency(like INR,dollars,Euro) used, the symbols(€,$,₹) used , the units in which the weights , temperature are measured. Another example could be the use of lakhs , crores for mentioning any financial figures in some countries while others use millions, billions.&lt;br /&gt;
#There could also be a difference in the formats used for a same thing. For example the format of writing dates and times vary from one region to another.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* We also have to be careful that we cover all the sensitive topics and issues particular to a language or region.&lt;br /&gt;
&lt;br /&gt;
:Similarly there are many other factors that we need to take care of when we support internationalization for a particular language in a particular region.&lt;br /&gt;
&lt;br /&gt;
= Internationalization in Rails =&lt;br /&gt;
&lt;br /&gt;
:Internationalization support was extended from Rails version 2.2. So in order to internationalize a rails application, it has to be migrated :to Rails 2.2 or above. Every static string in the Rails framework — e.g. Active Record validation messages, time and date formats — have :been internationalized.&lt;br /&gt;
&lt;br /&gt;
:Following needs to be done in order to internationalize a rails application:&lt;br /&gt;
:#Ensure support for internationalization by migrating to appropriate version of rails if needed.&lt;br /&gt;
:#Tell rails where to find the appropriate translations files&lt;br /&gt;
:#Tell rails how to switch locales&lt;br /&gt;
&lt;br /&gt;
::YAML (.yml) or plain Ruby (.rb) files are used for storing translations.&lt;br /&gt;
&lt;br /&gt;
== History ==&lt;br /&gt;
&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100pt&amp;quot;| Ruby 2.2    || Internationalization support was extended from this version of Rails.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 2.3    || Additional feature for Localized Views was added in this version. The view files were rendered with an extension of the locale name.I18n#available_locales and I18n::SimpleBackend#available_locales is available to retrieve an array of available locales.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 3.0    || Some additional features were added to the I18n gem for speed improvements like default translations for attributes,automatic pull for translations on form submit, etc.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 3.1    || I18n namespace lookup support removed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Ways to configure Internationalization in Rails ==&lt;br /&gt;
&lt;br /&gt;
:We can set up a rails application to support internationalization in a number of ways. Below are the various ways to configure our rails application for internationalization.&lt;br /&gt;
&lt;br /&gt;
#'''Configure the I18n module:'''&amp;lt;br&amp;gt;Rails adds all .rb and .yml files from the config/locales directory to your translations load path, automatically. This is the default setting provided by the [https://github.com/svenfuchs/i18n I18n gem]. In order to override this setting we have to make changes in the application.rb files that have instructions on how to add locales from another directory and how to set a different default locale.&lt;br /&gt;
#'''Custom I18n Configuration Setup:'''&amp;lt;br&amp;gt;Optionally, the above code can be placed anywhere in the application preferably in initializers.&lt;br /&gt;
#'''Setting and passing locale:'''&amp;lt;br&amp;gt;The above two steps help setup a default locale throughout the application. But in case we have to provide our application in different languages, we can setup the application default locale in the application.rb and then set the locale using the application-controller.rb before_action. We can then pass the locale we want as a query param for example http://study.com/books?locale=es&lt;br /&gt;
#'''Setting the locale from the domain name:'''&amp;lt;br&amp;gt;Similar to option 3 but instead of passing the locale as a query param, the locale is a part of the domain name itself. Example http://study.es&lt;br /&gt;
::You can implement it like this in your ApplicationController before_action&lt;br /&gt;
#'''Setting the locale from the URL params:'''&amp;lt;br&amp;gt;&lt;br /&gt;
##This can be a tedious task as we have to pass the locale on each request. &lt;br /&gt;
##Rails provides us an alternative for &amp;quot;centralizing dynamic decisions about the URLs&amp;quot; in its ApplicationController#default_url_options and helper methods are dependent on it (by implementing/overriding this method). This will now automatically include the locale param in the query string&lt;br /&gt;
##We can also set the locale in the URL route. For example -http://study.com/es/books .This is achievable by using over-riding default_url_options. You just have to set up your routes with scoping option in routes.rb. &lt;br /&gt;
#'''Setting the locale from client supplied information:'''&amp;lt;br&amp;gt;This can be done in 3 ways&lt;br /&gt;
##Using the default locale of the client browser&lt;br /&gt;
##Using client location to select the locale&lt;br /&gt;
##Saving the users choice of locale as a part of user profile&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Internationalizing Rails application ==&lt;br /&gt;
&lt;br /&gt;
:After your application is prepared for internationalization, we need to use the feature in our application. &lt;br /&gt;
:This can be done in the following ways:&lt;br /&gt;
&lt;br /&gt;
1.'''Adding Translations:'''&lt;br /&gt;
:In order to internationalize rails code, replace the strings with calls to  the ‘t’ helper.&amp;lt;br&amp;gt;For example: &lt;br /&gt;
 class HelloWorld &lt;br /&gt;
  def sayHello&lt;br /&gt;
    puts t(:hello_world)&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;%=t :hello_world %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:The helper method t also catches missing translations and displays appropriate error message.&lt;br /&gt;
 &amp;lt;nowiki /&amp;gt;# config/locales/en.yml&lt;br /&gt;
 en: hello_world: Hello world!&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki /&amp;gt;# config/locales/es.yml&lt;br /&gt;
 es: hello_world: hola mundo&lt;br /&gt;
&lt;br /&gt;
2.'''Passing variables to translation:'''&lt;br /&gt;
:You can use variables in the translation messages and pass their values from the view.&lt;br /&gt;
 en:&lt;br /&gt;
 portal: &amp;quot;Mypack&amp;quot;&lt;br /&gt;
   university:&lt;br /&gt;
    ncsu:&lt;br /&gt;
    description: ! 'NCSU student information is accessed on %{portal_name}’ &lt;br /&gt;
&lt;br /&gt;
 t('.description', portal_name: t(‘portal’))&lt;br /&gt;
&lt;br /&gt;
3.'''Adding date/ time formats:'''&lt;br /&gt;
:OK! Now let's add a timestamp to the view, so we can demo the date/time localization feature as well. To localize the time format you pass the Time object to I18n.l or (preferably) use ‘l’ helper. You can pick a format by passing the :format option — by default the :default format is used.&lt;br /&gt;
:In the view file:&lt;br /&gt;
 &amp;lt;p&amp;gt;&amp;lt;%= l Time.now, format: :short %&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt;
:In the yml file:&lt;br /&gt;
  es:&lt;br /&gt;
   time:&lt;br /&gt;
     formats:&lt;br /&gt;
       short: &amp;quot; Son las %H&amp;quot;&lt;br /&gt;
&lt;br /&gt;
4.'''Inflection rules for locales other than english:'''&lt;br /&gt;
:Rails 4.0 provides a feature to define inflection rules (singularization and pluralization)  in config/initializers/inflections.rb. &lt;br /&gt;
&lt;br /&gt;
5.'''Localized views:'''&lt;br /&gt;
:For static websites available in different languages or for large static content, localized views is a useful feature. This feature enables having separate view file for different locales. For example for default locale we can have show.html.erb file while for Spanish we can have show.es.html.erb. Thus we don’t need to maintain long .yml files for each supported locale for long static pages.&lt;/div&gt;</summary>
		<author><name>Srparadk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w18_bs&amp;diff=76083</id>
		<title>CSC/ECE 517 Fall 2013/ch1 1w18 bs</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w18_bs&amp;diff=76083"/>
		<updated>2013-09-16T20:42:19Z</updated>

		<summary type="html">&lt;p&gt;Srparadk: /* Internationalizing Rails application */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Internationalization in Rails&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
:In general when we start a conversation, the first default language of communication we use is English, but if the other person is not familiar with English we try and translate our dialogue in a language that the person is familiar with. Similarly whenever we write a program or a document we write it in English by default. But what if someone who is not familiar with English wants to read your program or code? The simple solution is that we translate program or code into a language that the person is familiar with. And for this, we use a term called internationalization.&lt;br /&gt;
&lt;br /&gt;
:Internationalization is a way by which we can view an application in various languages without actually making changes to the code of the application. This saves us a lot of time and effort, as we don’t have to write or edit the same code or document in all the copies.&lt;br /&gt;
&lt;br /&gt;
:Internationalization has an acronym, rather more of a numeronym ,which is i18n where the number 18 represents the number of letters between the first and last letters in the word internationalization.&lt;br /&gt;
&lt;br /&gt;
== Aspects to consider in Internationalization ==&lt;br /&gt;
&lt;br /&gt;
:Now when we are to change our application according to a particular language or a region , we need to keep in mind numerous points that are important, implicit, particular or sensitive to that language or region. Like for example when we take a language into consideration for which our application needs to be translated, we need to consider the spoken and written aspects of that language. Also, there might be a case when we have the same language but it differs from one region to other. For this we need to keep in mind the typical change in the use of words, grammar and symbol for each region that uses the same language. Our application must also provide support for the varied writing conventions that differ from a language to another language or from one region to another.&lt;br /&gt;
&lt;br /&gt;
:Below are the examples of the points we need to keep in mind while we provide internationalization to our application :&lt;br /&gt;
&lt;br /&gt;
* Language :&lt;br /&gt;
&lt;br /&gt;
:Here the i18n support to an application needs to provide the character encoding keeping in mind the following points:&lt;br /&gt;
&lt;br /&gt;
#The written language differs. For example most of the languages like English, French, German follow a script that can have inputs from a standard keyboard. But there are other languages like Hindi, Marathi, Sanskrit that follow a script called Devnagri and this cannot be directly typed in from a standard keyboard. So if we have to provide support for these languages we need to support the translation of the characters used in these scripts.&lt;br /&gt;
#The way we write also differs and needs to included in our i18n support. For example most of the languages follow a left-right direction while writing but some languages like Urdu tend to follow a right-left direction.&lt;br /&gt;
#The numbering symbols also vary from language to language. So when we display or accept any text with numbers, we must have i18n to support this mapping.&lt;br /&gt;
#The languages also differ in the use of grammar and structure of the sentences.For example the grammar rules and structure formation in English is way different than the one followed by another language like Sanskrit.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Culture and Writing Conventions:&lt;br /&gt;
&lt;br /&gt;
:Even if the language with the same characters and grammar is used, the use of the language , the symbols , the way of writing and many other things change with change in the region.&lt;br /&gt;
:Following are some of the examples:&lt;br /&gt;
&lt;br /&gt;
#There are some cultures that have some regulations about having a middle name as father’s name but other cultures don’t necessary include the middle name.&lt;br /&gt;
#There might be cases when there are different names or terminologies used in different cultures for the same purpose. For example, to identify a citizen uniquely US has the system of SSN while India is in the process of implementing this by using the term as Aadhar number.&lt;br /&gt;
#Another example of difference in the writing convention can be taken as that of a postal code. Some countries have 6 digit postal codes while others have 5.&lt;br /&gt;
#There is a difference in the use of many other things like the currency(like INR,dollars,Euro) used, the symbols(€,$,₹) used , the units in which the weights , temperature are measured. Another example could be the use of lakhs , crores for mentioning any financial figures in some countries while others use millions, billions.&lt;br /&gt;
#There could also be a difference in the formats used for a same thing. For example the format of writing dates and times vary from one region to another.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* We also have to be careful that we cover all the sensitive topics and issues particular to a language or region.&lt;br /&gt;
&lt;br /&gt;
:Similarly there are many other factors that we need to take care of when we support internationalization for a particular language in a particular region.&lt;br /&gt;
&lt;br /&gt;
= Internationalization in Rails =&lt;br /&gt;
&lt;br /&gt;
:Internationalization support was extended from Rails version 2.2. So in order to internationalize a rails application, it has to be migrated :to Rails 2.2 or above. Every static string in the Rails framework — e.g. Active Record validation messages, time and date formats — have :been internationalized.&lt;br /&gt;
&lt;br /&gt;
:Following needs to be done in order to internationalize a rails application:&lt;br /&gt;
:#Ensure support for internationalization by migrating to appropriate version of rails if needed.&lt;br /&gt;
:#Tell rails where to find the appropriate translations files&lt;br /&gt;
:#Tell rails how to switch locales&lt;br /&gt;
&lt;br /&gt;
::YAML (.yml) or plain Ruby (.rb) files are used for storing translations.&lt;br /&gt;
&lt;br /&gt;
== History ==&lt;br /&gt;
&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100pt&amp;quot;| Ruby 2.2    || Internationalization support was extended from this version of Rails.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 2.3    || Additional feature for Localized Views was added in this version. The view files were rendered with an extension of the locale name.I18n#available_locales and I18n::SimpleBackend#available_locales is available to retrieve an array of available locales.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 3.0    || Some additional features were added to the I18n gem for speed improvements like default translations for attributes,automatic pull for translations on form submit, etc.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 3.1    || I18n namespace lookup support removed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Ways to configure Internationalization in Rails ==&lt;br /&gt;
&lt;br /&gt;
:We can set up a rails application to support internationalization in a number of ways. Below are the various ways to configure our rails application for internationalization.&lt;br /&gt;
&lt;br /&gt;
#'''Configure the I18n module:'''&amp;lt;br&amp;gt;Rails adds all .rb and .yml files from the config/locales directory to your translations load path, automatically. This is the default setting provided by the [https://github.com/svenfuchs/i18n I18n gem]. In order to override this setting we have to make changes in the application.rb files that have instructions on how to add locales from another directory and how to set a different default locale.&lt;br /&gt;
#'''Custom I18n Configuration Setup:'''&amp;lt;br&amp;gt;Optionally, the above code can be placed anywhere in the application preferably in initializers.&lt;br /&gt;
#'''Setting and passing locale:'''&amp;lt;br&amp;gt;The above two steps help setup a default locale throughout the application. But in case we have to provide our application in different languages, we can setup the application default locale in the application.rb and then set the locale using the application-controller.rb before_action. We can then pass the locale we want as a query param for example http://study.com/books?locale=es&lt;br /&gt;
#'''Setting the locale from the domain name:'''&amp;lt;br&amp;gt;Similar to option 3 but instead of passing the locale as a query param, the locale is a part of the domain name itself. Example http://study.es&lt;br /&gt;
::You can implement it like this in your ApplicationController before_action&lt;br /&gt;
#'''Setting the locale from the URL params:'''&amp;lt;br&amp;gt;&lt;br /&gt;
##This can be a tedious task as we have to pass the locale on each request. &lt;br /&gt;
##Rails provides us an alternative for &amp;quot;centralizing dynamic decisions about the URLs&amp;quot; in its ApplicationController#default_url_options and helper methods are dependent on it (by implementing/overriding this method). This will now automatically include the locale param in the query string&lt;br /&gt;
##We can also set the locale in the URL route. For example -http://study.com/es/books .This is achievable by using over-riding default_url_options. You just have to set up your routes with scoping option in routes.rb. &lt;br /&gt;
#'''Setting the locale from client supplied information:'''&amp;lt;br&amp;gt;This can be done in 3 ways&lt;br /&gt;
##Using the default locale of the client browser&lt;br /&gt;
##Using client location to select the locale&lt;br /&gt;
##Saving the users choice of locale as a part of user profile&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Internationalizing Rails application ==&lt;br /&gt;
&lt;br /&gt;
:After your application is prepared for internationalization, we need to use the feature in our application. &lt;br /&gt;
:This can be done in the following ways:&lt;br /&gt;
&lt;br /&gt;
:1.'''Adding Translations:'''&amp;lt;br&amp;gt;In order to internationalize rails code, replace the strings with calls to  the ‘t’ helper.&amp;lt;br&amp;gt;For example: &lt;br /&gt;
 class HelloWorld &lt;br /&gt;
  def sayHello&lt;br /&gt;
    puts t(:hello_world)&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;%=t :hello_world %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The helper method t also catches missing translations and displays appropriate error message.&lt;br /&gt;
 &amp;lt;nowiki /&amp;gt;# config/locales/en.yml&lt;br /&gt;
 en: hello_world: Hello world!&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki /&amp;gt;# config/locales/es.yml&lt;br /&gt;
 es: hello_world: hola mundo&lt;br /&gt;
&lt;br /&gt;
:2.'''Passing variables to translation:'''&amp;lt;br&amp;gt;You can use variables in the translation messages and pass their values from the view.&amp;lt;br&amp;gt;&lt;br /&gt;
 en:&lt;br /&gt;
 portal: &amp;quot;Mypack&amp;quot;&lt;br /&gt;
   university:&lt;br /&gt;
    ncsu:&lt;br /&gt;
    description: ! 'NCSU student information is accessed on %{portal_name}’ &lt;br /&gt;
&lt;br /&gt;
 t('.description', portal_name: t(‘portal’))&lt;br /&gt;
&lt;br /&gt;
:3.'''Adding date/ time formats:'''&lt;br /&gt;
::OK! Now let's add a timestamp to the view, so we can demo the date/time localization feature as well. To localize the time format you pass the Time object to I18n.l or (preferably) use ‘l’ helper. You can pick a format by passing the :format option — by default the :default format is used.&lt;br /&gt;
::In the view file:&lt;br /&gt;
 &amp;lt;p&amp;gt;&amp;lt;%= l Time.now, format: :short %&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt;
In the yml file:&lt;br /&gt;
 es:&lt;br /&gt;
  time:&lt;br /&gt;
    formats:&lt;br /&gt;
      short: &amp;quot; Son las %H&amp;quot;&lt;br /&gt;
&lt;br /&gt;
4.	Inflection rules for locales other than english&lt;br /&gt;
Rails 4.0 provides a feature to define inflection rules (singularization and pluralization)  in config/initializers/inflections.rb. &lt;br /&gt;
&lt;br /&gt;
5.	Localized views&lt;br /&gt;
For static websites available in different languages or for large static content, localized views is a useful feature. This feature enables having separate view file for different locales. For example for default locale we can have show.html.erb file while for Spanish we can have show.es.html.erb. Thus we don’t need to maintain long .yml files for each supported locale for long static pages.&lt;/div&gt;</summary>
		<author><name>Srparadk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w18_bs&amp;diff=76082</id>
		<title>CSC/ECE 517 Fall 2013/ch1 1w18 bs</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w18_bs&amp;diff=76082"/>
		<updated>2013-09-16T20:40:09Z</updated>

		<summary type="html">&lt;p&gt;Srparadk: /* Internationalizing Rails application */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Internationalization in Rails&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
:In general when we start a conversation, the first default language of communication we use is English, but if the other person is not familiar with English we try and translate our dialogue in a language that the person is familiar with. Similarly whenever we write a program or a document we write it in English by default. But what if someone who is not familiar with English wants to read your program or code? The simple solution is that we translate program or code into a language that the person is familiar with. And for this, we use a term called internationalization.&lt;br /&gt;
&lt;br /&gt;
:Internationalization is a way by which we can view an application in various languages without actually making changes to the code of the application. This saves us a lot of time and effort, as we don’t have to write or edit the same code or document in all the copies.&lt;br /&gt;
&lt;br /&gt;
:Internationalization has an acronym, rather more of a numeronym ,which is i18n where the number 18 represents the number of letters between the first and last letters in the word internationalization.&lt;br /&gt;
&lt;br /&gt;
== Aspects to consider in Internationalization ==&lt;br /&gt;
&lt;br /&gt;
:Now when we are to change our application according to a particular language or a region , we need to keep in mind numerous points that are important, implicit, particular or sensitive to that language or region. Like for example when we take a language into consideration for which our application needs to be translated, we need to consider the spoken and written aspects of that language. Also, there might be a case when we have the same language but it differs from one region to other. For this we need to keep in mind the typical change in the use of words, grammar and symbol for each region that uses the same language. Our application must also provide support for the varied writing conventions that differ from a language to another language or from one region to another.&lt;br /&gt;
&lt;br /&gt;
:Below are the examples of the points we need to keep in mind while we provide internationalization to our application :&lt;br /&gt;
&lt;br /&gt;
* Language :&lt;br /&gt;
&lt;br /&gt;
:Here the i18n support to an application needs to provide the character encoding keeping in mind the following points:&lt;br /&gt;
&lt;br /&gt;
#The written language differs. For example most of the languages like English, French, German follow a script that can have inputs from a standard keyboard. But there are other languages like Hindi, Marathi, Sanskrit that follow a script called Devnagri and this cannot be directly typed in from a standard keyboard. So if we have to provide support for these languages we need to support the translation of the characters used in these scripts.&lt;br /&gt;
#The way we write also differs and needs to included in our i18n support. For example most of the languages follow a left-right direction while writing but some languages like Urdu tend to follow a right-left direction.&lt;br /&gt;
#The numbering symbols also vary from language to language. So when we display or accept any text with numbers, we must have i18n to support this mapping.&lt;br /&gt;
#The languages also differ in the use of grammar and structure of the sentences.For example the grammar rules and structure formation in English is way different than the one followed by another language like Sanskrit.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Culture and Writing Conventions:&lt;br /&gt;
&lt;br /&gt;
:Even if the language with the same characters and grammar is used, the use of the language , the symbols , the way of writing and many other things change with change in the region.&lt;br /&gt;
:Following are some of the examples:&lt;br /&gt;
&lt;br /&gt;
#There are some cultures that have some regulations about having a middle name as father’s name but other cultures don’t necessary include the middle name.&lt;br /&gt;
#There might be cases when there are different names or terminologies used in different cultures for the same purpose. For example, to identify a citizen uniquely US has the system of SSN while India is in the process of implementing this by using the term as Aadhar number.&lt;br /&gt;
#Another example of difference in the writing convention can be taken as that of a postal code. Some countries have 6 digit postal codes while others have 5.&lt;br /&gt;
#There is a difference in the use of many other things like the currency(like INR,dollars,Euro) used, the symbols(€,$,₹) used , the units in which the weights , temperature are measured. Another example could be the use of lakhs , crores for mentioning any financial figures in some countries while others use millions, billions.&lt;br /&gt;
#There could also be a difference in the formats used for a same thing. For example the format of writing dates and times vary from one region to another.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* We also have to be careful that we cover all the sensitive topics and issues particular to a language or region.&lt;br /&gt;
&lt;br /&gt;
:Similarly there are many other factors that we need to take care of when we support internationalization for a particular language in a particular region.&lt;br /&gt;
&lt;br /&gt;
= Internationalization in Rails =&lt;br /&gt;
&lt;br /&gt;
:Internationalization support was extended from Rails version 2.2. So in order to internationalize a rails application, it has to be migrated :to Rails 2.2 or above. Every static string in the Rails framework — e.g. Active Record validation messages, time and date formats — have :been internationalized.&lt;br /&gt;
&lt;br /&gt;
:Following needs to be done in order to internationalize a rails application:&lt;br /&gt;
:#Ensure support for internationalization by migrating to appropriate version of rails if needed.&lt;br /&gt;
:#Tell rails where to find the appropriate translations files&lt;br /&gt;
:#Tell rails how to switch locales&lt;br /&gt;
&lt;br /&gt;
::YAML (.yml) or plain Ruby (.rb) files are used for storing translations.&lt;br /&gt;
&lt;br /&gt;
== History ==&lt;br /&gt;
&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100pt&amp;quot;| Ruby 2.2    || Internationalization support was extended from this version of Rails.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 2.3    || Additional feature for Localized Views was added in this version. The view files were rendered with an extension of the locale name.I18n#available_locales and I18n::SimpleBackend#available_locales is available to retrieve an array of available locales.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 3.0    || Some additional features were added to the I18n gem for speed improvements like default translations for attributes,automatic pull for translations on form submit, etc.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 3.1    || I18n namespace lookup support removed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Ways to configure Internationalization in Rails ==&lt;br /&gt;
&lt;br /&gt;
:We can set up a rails application to support internationalization in a number of ways. Below are the various ways to configure our rails application for internationalization.&lt;br /&gt;
&lt;br /&gt;
#'''Configure the I18n module:'''&amp;lt;br&amp;gt;Rails adds all .rb and .yml files from the config/locales directory to your translations load path, automatically. This is the default setting provided by the [https://github.com/svenfuchs/i18n I18n gem]. In order to override this setting we have to make changes in the application.rb files that have instructions on how to add locales from another directory and how to set a different default locale.&lt;br /&gt;
#'''Custom I18n Configuration Setup:'''&amp;lt;br&amp;gt;Optionally, the above code can be placed anywhere in the application preferably in initializers.&lt;br /&gt;
#'''Setting and passing locale:'''&amp;lt;br&amp;gt;The above two steps help setup a default locale throughout the application. But in case we have to provide our application in different languages, we can setup the application default locale in the application.rb and then set the locale using the application-controller.rb before_action. We can then pass the locale we want as a query param for example http://study.com/books?locale=es&lt;br /&gt;
#'''Setting the locale from the domain name:'''&amp;lt;br&amp;gt;Similar to option 3 but instead of passing the locale as a query param, the locale is a part of the domain name itself. Example http://study.es&lt;br /&gt;
::You can implement it like this in your ApplicationController before_action&lt;br /&gt;
#'''Setting the locale from the URL params:'''&amp;lt;br&amp;gt;&lt;br /&gt;
##This can be a tedious task as we have to pass the locale on each request. &lt;br /&gt;
##Rails provides us an alternative for &amp;quot;centralizing dynamic decisions about the URLs&amp;quot; in its ApplicationController#default_url_options and helper methods are dependent on it (by implementing/overriding this method). This will now automatically include the locale param in the query string&lt;br /&gt;
##We can also set the locale in the URL route. For example -http://study.com/es/books .This is achievable by using over-riding default_url_options. You just have to set up your routes with scoping option in routes.rb. &lt;br /&gt;
#'''Setting the locale from client supplied information:'''&amp;lt;br&amp;gt;This can be done in 3 ways&lt;br /&gt;
##Using the default locale of the client browser&lt;br /&gt;
##Using client location to select the locale&lt;br /&gt;
##Saving the users choice of locale as a part of user profile&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Internationalizing Rails application ==&lt;br /&gt;
&lt;br /&gt;
:After your application is prepared for internationalization, we need to use the feature in our application. &lt;br /&gt;
:This can be done in the following ways:&lt;br /&gt;
&lt;br /&gt;
:1.'''Adding Translations:'''&amp;lt;br&amp;gt;In order to internationalize rails code, replace the strings with calls to  the ‘t’ helper.&amp;lt;br&amp;gt;For example: &lt;br /&gt;
:::class HelloWorld &amp;lt;br&amp;gt;def sayHello&amp;lt;br&amp;gt;  puts t(:hello_world)&amp;lt;br&amp;gt;end&amp;lt;br&amp;gt;end&amp;lt;br&amp;gt;or&amp;lt;br&amp;gt;  &amp;lt;%=t :hello_world %&amp;gt;&amp;lt;br&amp;gt;The helper method t also catches missing translations and displays appropriate error message.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;nowiki /&amp;gt;# config/locales/en.yml&amp;lt;br&amp;gt;en:&amp;lt;br&amp;gt; hello_world: Hello world!&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;nowiki /&amp;gt;# config/locales/es.yml&amp;lt;br&amp;gt;es:&amp;lt;br&amp;gt;hello_world: hola mundo&lt;br /&gt;
&lt;br /&gt;
:2.'''Passing variables to translation:'''&amp;lt;br&amp;gt;You can use variables in the translation messages and pass their values from the view.&amp;lt;br&amp;gt;&lt;br /&gt;
 en:&lt;br /&gt;
 portal: &amp;quot;Mypack&amp;quot;&lt;br /&gt;
   university:&lt;br /&gt;
    ncsu:&lt;br /&gt;
    description: ! 'NCSU student information is accessed on %{portal_name}’ &lt;br /&gt;
&lt;br /&gt;
 t('.description', portal_name: t(‘portal’))&lt;br /&gt;
&lt;br /&gt;
:3.'''Adding date/ time formats:'''&lt;br /&gt;
::OK! Now let's add a timestamp to the view, so we can demo the date/time localization feature as well. To localize the time format you pass the Time object to I18n.l or (preferably) use ‘l’ helper. You can pick a format by passing the :format option — by default the :default format is used.&lt;br /&gt;
::In the view file:&lt;br /&gt;
 &amp;lt;p&amp;gt;&amp;lt;%= l Time.now, format: :short %&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt;
In the yml file:&lt;br /&gt;
 es:&lt;br /&gt;
  time:&lt;br /&gt;
    formats:&lt;br /&gt;
      short: &amp;quot; Son las %H&amp;quot;&lt;br /&gt;
&lt;br /&gt;
4.	Inflection rules for locales other than english&lt;br /&gt;
Rails 4.0 provides a feature to define inflection rules (singularization and pluralization)  in config/initializers/inflections.rb. &lt;br /&gt;
&lt;br /&gt;
5.	Localized views&lt;br /&gt;
For static websites available in different languages or for large static content, localized views is a useful feature. This feature enables having separate view file for different locales. For example for default locale we can have show.html.erb file while for Spanish we can have show.es.html.erb. Thus we don’t need to maintain long .yml files for each supported locale for long static pages.&lt;/div&gt;</summary>
		<author><name>Srparadk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w18_bs&amp;diff=76080</id>
		<title>CSC/ECE 517 Fall 2013/ch1 1w18 bs</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w18_bs&amp;diff=76080"/>
		<updated>2013-09-16T20:38:03Z</updated>

		<summary type="html">&lt;p&gt;Srparadk: /* Internationalizing Rails application */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Internationalization in Rails&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
:In general when we start a conversation, the first default language of communication we use is English, but if the other person is not familiar with English we try and translate our dialogue in a language that the person is familiar with. Similarly whenever we write a program or a document we write it in English by default. But what if someone who is not familiar with English wants to read your program or code? The simple solution is that we translate program or code into a language that the person is familiar with. And for this, we use a term called internationalization.&lt;br /&gt;
&lt;br /&gt;
:Internationalization is a way by which we can view an application in various languages without actually making changes to the code of the application. This saves us a lot of time and effort, as we don’t have to write or edit the same code or document in all the copies.&lt;br /&gt;
&lt;br /&gt;
:Internationalization has an acronym, rather more of a numeronym ,which is i18n where the number 18 represents the number of letters between the first and last letters in the word internationalization.&lt;br /&gt;
&lt;br /&gt;
== Aspects to consider in Internationalization ==&lt;br /&gt;
&lt;br /&gt;
:Now when we are to change our application according to a particular language or a region , we need to keep in mind numerous points that are important, implicit, particular or sensitive to that language or region. Like for example when we take a language into consideration for which our application needs to be translated, we need to consider the spoken and written aspects of that language. Also, there might be a case when we have the same language but it differs from one region to other. For this we need to keep in mind the typical change in the use of words, grammar and symbol for each region that uses the same language. Our application must also provide support for the varied writing conventions that differ from a language to another language or from one region to another.&lt;br /&gt;
&lt;br /&gt;
:Below are the examples of the points we need to keep in mind while we provide internationalization to our application :&lt;br /&gt;
&lt;br /&gt;
* Language :&lt;br /&gt;
&lt;br /&gt;
:Here the i18n support to an application needs to provide the character encoding keeping in mind the following points:&lt;br /&gt;
&lt;br /&gt;
#The written language differs. For example most of the languages like English, French, German follow a script that can have inputs from a standard keyboard. But there are other languages like Hindi, Marathi, Sanskrit that follow a script called Devnagri and this cannot be directly typed in from a standard keyboard. So if we have to provide support for these languages we need to support the translation of the characters used in these scripts.&lt;br /&gt;
#The way we write also differs and needs to included in our i18n support. For example most of the languages follow a left-right direction while writing but some languages like Urdu tend to follow a right-left direction.&lt;br /&gt;
#The numbering symbols also vary from language to language. So when we display or accept any text with numbers, we must have i18n to support this mapping.&lt;br /&gt;
#The languages also differ in the use of grammar and structure of the sentences.For example the grammar rules and structure formation in English is way different than the one followed by another language like Sanskrit.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Culture and Writing Conventions:&lt;br /&gt;
&lt;br /&gt;
:Even if the language with the same characters and grammar is used, the use of the language , the symbols , the way of writing and many other things change with change in the region.&lt;br /&gt;
:Following are some of the examples:&lt;br /&gt;
&lt;br /&gt;
#There are some cultures that have some regulations about having a middle name as father’s name but other cultures don’t necessary include the middle name.&lt;br /&gt;
#There might be cases when there are different names or terminologies used in different cultures for the same purpose. For example, to identify a citizen uniquely US has the system of SSN while India is in the process of implementing this by using the term as Aadhar number.&lt;br /&gt;
#Another example of difference in the writing convention can be taken as that of a postal code. Some countries have 6 digit postal codes while others have 5.&lt;br /&gt;
#There is a difference in the use of many other things like the currency(like INR,dollars,Euro) used, the symbols(€,$,₹) used , the units in which the weights , temperature are measured. Another example could be the use of lakhs , crores for mentioning any financial figures in some countries while others use millions, billions.&lt;br /&gt;
#There could also be a difference in the formats used for a same thing. For example the format of writing dates and times vary from one region to another.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* We also have to be careful that we cover all the sensitive topics and issues particular to a language or region.&lt;br /&gt;
&lt;br /&gt;
:Similarly there are many other factors that we need to take care of when we support internationalization for a particular language in a particular region.&lt;br /&gt;
&lt;br /&gt;
= Internationalization in Rails =&lt;br /&gt;
&lt;br /&gt;
:Internationalization support was extended from Rails version 2.2. So in order to internationalize a rails application, it has to be migrated :to Rails 2.2 or above. Every static string in the Rails framework — e.g. Active Record validation messages, time and date formats — have :been internationalized.&lt;br /&gt;
&lt;br /&gt;
:Following needs to be done in order to internationalize a rails application:&lt;br /&gt;
:#Ensure support for internationalization by migrating to appropriate version of rails if needed.&lt;br /&gt;
:#Tell rails where to find the appropriate translations files&lt;br /&gt;
:#Tell rails how to switch locales&lt;br /&gt;
&lt;br /&gt;
::YAML (.yml) or plain Ruby (.rb) files are used for storing translations.&lt;br /&gt;
&lt;br /&gt;
== History ==&lt;br /&gt;
&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100pt&amp;quot;| Ruby 2.2    || Internationalization support was extended from this version of Rails.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 2.3    || Additional feature for Localized Views was added in this version. The view files were rendered with an extension of the locale name.I18n#available_locales and I18n::SimpleBackend#available_locales is available to retrieve an array of available locales.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 3.0    || Some additional features were added to the I18n gem for speed improvements like default translations for attributes,automatic pull for translations on form submit, etc.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 3.1    || I18n namespace lookup support removed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Ways to configure Internationalization in Rails ==&lt;br /&gt;
&lt;br /&gt;
:We can set up a rails application to support internationalization in a number of ways. Below are the various ways to configure our rails application for internationalization.&lt;br /&gt;
&lt;br /&gt;
#'''Configure the I18n module:'''&amp;lt;br&amp;gt;Rails adds all .rb and .yml files from the config/locales directory to your translations load path, automatically. This is the default setting provided by the [https://github.com/svenfuchs/i18n I18n gem]. In order to override this setting we have to make changes in the application.rb files that have instructions on how to add locales from another directory and how to set a different default locale.&lt;br /&gt;
#'''Custom I18n Configuration Setup:'''&amp;lt;br&amp;gt;Optionally, the above code can be placed anywhere in the application preferably in initializers.&lt;br /&gt;
#'''Setting and passing locale:'''&amp;lt;br&amp;gt;The above two steps help setup a default locale throughout the application. But in case we have to provide our application in different languages, we can setup the application default locale in the application.rb and then set the locale using the application-controller.rb before_action. We can then pass the locale we want as a query param for example http://study.com/books?locale=es&lt;br /&gt;
#'''Setting the locale from the domain name:'''&amp;lt;br&amp;gt;Similar to option 3 but instead of passing the locale as a query param, the locale is a part of the domain name itself. Example http://study.es&lt;br /&gt;
::You can implement it like this in your ApplicationController before_action&lt;br /&gt;
#'''Setting the locale from the URL params:'''&amp;lt;br&amp;gt;&lt;br /&gt;
##This can be a tedious task as we have to pass the locale on each request. &lt;br /&gt;
##Rails provides us an alternative for &amp;quot;centralizing dynamic decisions about the URLs&amp;quot; in its ApplicationController#default_url_options and helper methods are dependent on it (by implementing/overriding this method). This will now automatically include the locale param in the query string&lt;br /&gt;
##We can also set the locale in the URL route. For example -http://study.com/es/books .This is achievable by using over-riding default_url_options. You just have to set up your routes with scoping option in routes.rb. &lt;br /&gt;
#'''Setting the locale from client supplied information:'''&amp;lt;br&amp;gt;This can be done in 3 ways&lt;br /&gt;
##Using the default locale of the client browser&lt;br /&gt;
##Using client location to select the locale&lt;br /&gt;
##Saving the users choice of locale as a part of user profile&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Internationalizing Rails application ==&lt;br /&gt;
&lt;br /&gt;
:After your application is prepared for internationalization, we need to use the feature in our application. &lt;br /&gt;
:This can be done in the following ways:&lt;br /&gt;
&lt;br /&gt;
:1.'''Adding Translations:'''&amp;lt;br&amp;gt;In order to internationalize rails code, replace the strings with calls to  the ‘t’ helper.&amp;lt;br&amp;gt;For example: &lt;br /&gt;
:::class HelloWorld &amp;lt;br&amp;gt;def sayHello&amp;lt;br&amp;gt;  puts t(:hello_world)&amp;lt;br&amp;gt;end&amp;lt;br&amp;gt;end&amp;lt;br&amp;gt;or&amp;lt;br&amp;gt;  &amp;lt;%=t :hello_world %&amp;gt;&amp;lt;br&amp;gt;The helper method t also catches missing translations and displays appropriate error message.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;nowiki /&amp;gt;# config/locales/en.yml&amp;lt;br&amp;gt;en:&amp;lt;br&amp;gt; hello_world: Hello world!&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;nowiki /&amp;gt;# config/locales/es.yml&amp;lt;br&amp;gt;es:&amp;lt;br&amp;gt;hello_world: hola mundo&lt;br /&gt;
&lt;br /&gt;
:2.'''Passing variables to translation:'''&amp;lt;br&amp;gt;You can use variables in the translation messages and pass their values from the view.&amp;lt;br&amp;gt;&lt;br /&gt;
:: en:&amp;lt;br&amp;gt;portal: &amp;quot;Mypack&amp;quot;&amp;lt;br&amp;gt;university:&amp;lt;br&amp;gt;ncsu:&amp;lt;br&amp;gt;description: ! 'NCSU student information is accessed on %{portal_name}’&amp;lt;br&amp;gt;&amp;lt;br&amp;gt; t('.description', portal_name: t(‘portal’))&lt;br /&gt;
&lt;br /&gt;
:3.'''Adding date/ time formats:'''&lt;br /&gt;
::OK! Now let's add a timestamp to the view, so we can demo the date/time localization feature as well. To localize the time format you pass the Time object to I18n.l or (preferably) use ‘l’ helper. You can pick a format by passing the :format option — by default the :default format is used.&lt;br /&gt;
::In the view file:&lt;br /&gt;
 &amp;lt;p&amp;gt;&amp;lt;%= l Time.now, format: :short %&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt;
In the yml file:&lt;br /&gt;
 es:&lt;br /&gt;
  time:&lt;br /&gt;
    formats:&lt;br /&gt;
      short: &amp;quot; Son las %H&amp;quot;&lt;br /&gt;
&lt;br /&gt;
4.	Inflection rules for locales other than english&lt;br /&gt;
Rails 4.0 provides a feature to define inflection rules (singularization and pluralization)  in config/initializers/inflections.rb. &lt;br /&gt;
&lt;br /&gt;
5.	Localized views&lt;br /&gt;
For static websites available in different languages or for large static content, localized views is a useful feature. This feature enables having separate view file for different locales. For example for default locale we can have show.html.erb file while for Spanish we can have show.es.html.erb. Thus we don’t need to maintain long .yml files for each supported locale for long static pages.&lt;/div&gt;</summary>
		<author><name>Srparadk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w18_bs&amp;diff=76078</id>
		<title>CSC/ECE 517 Fall 2013/ch1 1w18 bs</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w18_bs&amp;diff=76078"/>
		<updated>2013-09-16T20:37:19Z</updated>

		<summary type="html">&lt;p&gt;Srparadk: /* Internationalizing Rails application */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Internationalization in Rails&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
:In general when we start a conversation, the first default language of communication we use is English, but if the other person is not familiar with English we try and translate our dialogue in a language that the person is familiar with. Similarly whenever we write a program or a document we write it in English by default. But what if someone who is not familiar with English wants to read your program or code? The simple solution is that we translate program or code into a language that the person is familiar with. And for this, we use a term called internationalization.&lt;br /&gt;
&lt;br /&gt;
:Internationalization is a way by which we can view an application in various languages without actually making changes to the code of the application. This saves us a lot of time and effort, as we don’t have to write or edit the same code or document in all the copies.&lt;br /&gt;
&lt;br /&gt;
:Internationalization has an acronym, rather more of a numeronym ,which is i18n where the number 18 represents the number of letters between the first and last letters in the word internationalization.&lt;br /&gt;
&lt;br /&gt;
== Aspects to consider in Internationalization ==&lt;br /&gt;
&lt;br /&gt;
:Now when we are to change our application according to a particular language or a region , we need to keep in mind numerous points that are important, implicit, particular or sensitive to that language or region. Like for example when we take a language into consideration for which our application needs to be translated, we need to consider the spoken and written aspects of that language. Also, there might be a case when we have the same language but it differs from one region to other. For this we need to keep in mind the typical change in the use of words, grammar and symbol for each region that uses the same language. Our application must also provide support for the varied writing conventions that differ from a language to another language or from one region to another.&lt;br /&gt;
&lt;br /&gt;
:Below are the examples of the points we need to keep in mind while we provide internationalization to our application :&lt;br /&gt;
&lt;br /&gt;
* Language :&lt;br /&gt;
&lt;br /&gt;
:Here the i18n support to an application needs to provide the character encoding keeping in mind the following points:&lt;br /&gt;
&lt;br /&gt;
#The written language differs. For example most of the languages like English, French, German follow a script that can have inputs from a standard keyboard. But there are other languages like Hindi, Marathi, Sanskrit that follow a script called Devnagri and this cannot be directly typed in from a standard keyboard. So if we have to provide support for these languages we need to support the translation of the characters used in these scripts.&lt;br /&gt;
#The way we write also differs and needs to included in our i18n support. For example most of the languages follow a left-right direction while writing but some languages like Urdu tend to follow a right-left direction.&lt;br /&gt;
#The numbering symbols also vary from language to language. So when we display or accept any text with numbers, we must have i18n to support this mapping.&lt;br /&gt;
#The languages also differ in the use of grammar and structure of the sentences.For example the grammar rules and structure formation in English is way different than the one followed by another language like Sanskrit.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Culture and Writing Conventions:&lt;br /&gt;
&lt;br /&gt;
:Even if the language with the same characters and grammar is used, the use of the language , the symbols , the way of writing and many other things change with change in the region.&lt;br /&gt;
:Following are some of the examples:&lt;br /&gt;
&lt;br /&gt;
#There are some cultures that have some regulations about having a middle name as father’s name but other cultures don’t necessary include the middle name.&lt;br /&gt;
#There might be cases when there are different names or terminologies used in different cultures for the same purpose. For example, to identify a citizen uniquely US has the system of SSN while India is in the process of implementing this by using the term as Aadhar number.&lt;br /&gt;
#Another example of difference in the writing convention can be taken as that of a postal code. Some countries have 6 digit postal codes while others have 5.&lt;br /&gt;
#There is a difference in the use of many other things like the currency(like INR,dollars,Euro) used, the symbols(€,$,₹) used , the units in which the weights , temperature are measured. Another example could be the use of lakhs , crores for mentioning any financial figures in some countries while others use millions, billions.&lt;br /&gt;
#There could also be a difference in the formats used for a same thing. For example the format of writing dates and times vary from one region to another.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* We also have to be careful that we cover all the sensitive topics and issues particular to a language or region.&lt;br /&gt;
&lt;br /&gt;
:Similarly there are many other factors that we need to take care of when we support internationalization for a particular language in a particular region.&lt;br /&gt;
&lt;br /&gt;
= Internationalization in Rails =&lt;br /&gt;
&lt;br /&gt;
:Internationalization support was extended from Rails version 2.2. So in order to internationalize a rails application, it has to be migrated :to Rails 2.2 or above. Every static string in the Rails framework — e.g. Active Record validation messages, time and date formats — have :been internationalized.&lt;br /&gt;
&lt;br /&gt;
:Following needs to be done in order to internationalize a rails application:&lt;br /&gt;
:#Ensure support for internationalization by migrating to appropriate version of rails if needed.&lt;br /&gt;
:#Tell rails where to find the appropriate translations files&lt;br /&gt;
:#Tell rails how to switch locales&lt;br /&gt;
&lt;br /&gt;
::YAML (.yml) or plain Ruby (.rb) files are used for storing translations.&lt;br /&gt;
&lt;br /&gt;
== History ==&lt;br /&gt;
&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100pt&amp;quot;| Ruby 2.2    || Internationalization support was extended from this version of Rails.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 2.3    || Additional feature for Localized Views was added in this version. The view files were rendered with an extension of the locale name.I18n#available_locales and I18n::SimpleBackend#available_locales is available to retrieve an array of available locales.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 3.0    || Some additional features were added to the I18n gem for speed improvements like default translations for attributes,automatic pull for translations on form submit, etc.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 3.1    || I18n namespace lookup support removed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Ways to configure Internationalization in Rails ==&lt;br /&gt;
&lt;br /&gt;
:We can set up a rails application to support internationalization in a number of ways. Below are the various ways to configure our rails application for internationalization.&lt;br /&gt;
&lt;br /&gt;
#'''Configure the I18n module:'''&amp;lt;br&amp;gt;Rails adds all .rb and .yml files from the config/locales directory to your translations load path, automatically. This is the default setting provided by the [https://github.com/svenfuchs/i18n I18n gem]. In order to override this setting we have to make changes in the application.rb files that have instructions on how to add locales from another directory and how to set a different default locale.&lt;br /&gt;
#'''Custom I18n Configuration Setup:'''&amp;lt;br&amp;gt;Optionally, the above code can be placed anywhere in the application preferably in initializers.&lt;br /&gt;
#'''Setting and passing locale:'''&amp;lt;br&amp;gt;The above two steps help setup a default locale throughout the application. But in case we have to provide our application in different languages, we can setup the application default locale in the application.rb and then set the locale using the application-controller.rb before_action. We can then pass the locale we want as a query param for example http://study.com/books?locale=es&lt;br /&gt;
#'''Setting the locale from the domain name:'''&amp;lt;br&amp;gt;Similar to option 3 but instead of passing the locale as a query param, the locale is a part of the domain name itself. Example http://study.es&lt;br /&gt;
::You can implement it like this in your ApplicationController before_action&lt;br /&gt;
#'''Setting the locale from the URL params:'''&amp;lt;br&amp;gt;&lt;br /&gt;
##This can be a tedious task as we have to pass the locale on each request. &lt;br /&gt;
##Rails provides us an alternative for &amp;quot;centralizing dynamic decisions about the URLs&amp;quot; in its ApplicationController#default_url_options and helper methods are dependent on it (by implementing/overriding this method). This will now automatically include the locale param in the query string&lt;br /&gt;
##We can also set the locale in the URL route. For example -http://study.com/es/books .This is achievable by using over-riding default_url_options. You just have to set up your routes with scoping option in routes.rb. &lt;br /&gt;
#'''Setting the locale from client supplied information:'''&amp;lt;br&amp;gt;This can be done in 3 ways&lt;br /&gt;
##Using the default locale of the client browser&lt;br /&gt;
##Using client location to select the locale&lt;br /&gt;
##Saving the users choice of locale as a part of user profile&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Internationalizing Rails application ==&lt;br /&gt;
&lt;br /&gt;
:After your application is prepared for internationalization, we need to use the feature in our application. &lt;br /&gt;
:This can be done in the following ways:&lt;br /&gt;
&lt;br /&gt;
:1.'''Adding Translations:'''&amp;lt;br&amp;gt;In order to internationalize rails code, replace the strings with calls to  the ‘t’ helper.&amp;lt;br&amp;gt;For example: &lt;br /&gt;
:::class HelloWorld &amp;lt;br&amp;gt;def sayHello&amp;lt;br&amp;gt;  puts t(:hello_world)&amp;lt;br&amp;gt;end&amp;lt;br&amp;gt;end&amp;lt;br&amp;gt;or&amp;lt;br&amp;gt;  &amp;lt;%=t :hello_world %&amp;gt;&amp;lt;br&amp;gt;The helper method t also catches missing translations and displays appropriate error message.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;nowiki /&amp;gt;# config/locales/en.yml&amp;lt;br&amp;gt;en:&amp;lt;br&amp;gt; hello_world: Hello world!&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;nowiki /&amp;gt;# config/locales/es.yml&amp;lt;br&amp;gt;es:&amp;lt;br&amp;gt;hello_world: hola mundo&lt;br /&gt;
&lt;br /&gt;
:2.'''Passing variables to translation:'''&amp;lt;br&amp;gt;You can use variables in the translation messages and pass their values from the view.&amp;lt;br&amp;gt;&lt;br /&gt;
::en:&amp;lt;br&amp;gt;portal: &amp;quot;Mypack&amp;quot;&amp;lt;br&amp;gt;university:&amp;lt;br&amp;gt;ncsu:&amp;lt;br&amp;gt;description: ! 'NCSU student information is accessed on %{portal_name}’&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;t('.description', portal_name: t(‘portal’))&lt;br /&gt;
&lt;br /&gt;
:3.'''Adding date/ time formats:'''&lt;br /&gt;
::OK! Now let's add a timestamp to the view, so we can demo the date/time localization feature as well. To localize the time format you pass the Time object to I18n.l or (preferably) use ‘l’ helper. You can pick a format by passing the :format option — by default the :default format is used.&lt;br /&gt;
::In the view file:&lt;br /&gt;
&amp;lt;p&amp;gt;&amp;lt;%= l Time.now, format: :short %&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt;
In the yml file:&lt;br /&gt;
 es:&lt;br /&gt;
  time:&lt;br /&gt;
    formats:&lt;br /&gt;
      short: &amp;quot; Son las %H&amp;quot;&lt;br /&gt;
&lt;br /&gt;
4.	Inflection rules for locales other than english&lt;br /&gt;
Rails 4.0 provides a feature to define inflection rules (singularization and pluralization)  in config/initializers/inflections.rb. &lt;br /&gt;
&lt;br /&gt;
5.	Localized views&lt;br /&gt;
For static websites available in different languages or for large static content, localized views is a useful feature. This feature enables having separate view file for different locales. For example for default locale we can have show.html.erb file while for Spanish we can have show.es.html.erb. Thus we don’t need to maintain long .yml files for each supported locale for long static pages.&lt;/div&gt;</summary>
		<author><name>Srparadk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w18_bs&amp;diff=76076</id>
		<title>CSC/ECE 517 Fall 2013/ch1 1w18 bs</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w18_bs&amp;diff=76076"/>
		<updated>2013-09-16T20:36:38Z</updated>

		<summary type="html">&lt;p&gt;Srparadk: /* Internationalizing Rails application */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Internationalization in Rails&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
:In general when we start a conversation, the first default language of communication we use is English, but if the other person is not familiar with English we try and translate our dialogue in a language that the person is familiar with. Similarly whenever we write a program or a document we write it in English by default. But what if someone who is not familiar with English wants to read your program or code? The simple solution is that we translate program or code into a language that the person is familiar with. And for this, we use a term called internationalization.&lt;br /&gt;
&lt;br /&gt;
:Internationalization is a way by which we can view an application in various languages without actually making changes to the code of the application. This saves us a lot of time and effort, as we don’t have to write or edit the same code or document in all the copies.&lt;br /&gt;
&lt;br /&gt;
:Internationalization has an acronym, rather more of a numeronym ,which is i18n where the number 18 represents the number of letters between the first and last letters in the word internationalization.&lt;br /&gt;
&lt;br /&gt;
== Aspects to consider in Internationalization ==&lt;br /&gt;
&lt;br /&gt;
:Now when we are to change our application according to a particular language or a region , we need to keep in mind numerous points that are important, implicit, particular or sensitive to that language or region. Like for example when we take a language into consideration for which our application needs to be translated, we need to consider the spoken and written aspects of that language. Also, there might be a case when we have the same language but it differs from one region to other. For this we need to keep in mind the typical change in the use of words, grammar and symbol for each region that uses the same language. Our application must also provide support for the varied writing conventions that differ from a language to another language or from one region to another.&lt;br /&gt;
&lt;br /&gt;
:Below are the examples of the points we need to keep in mind while we provide internationalization to our application :&lt;br /&gt;
&lt;br /&gt;
* Language :&lt;br /&gt;
&lt;br /&gt;
:Here the i18n support to an application needs to provide the character encoding keeping in mind the following points:&lt;br /&gt;
&lt;br /&gt;
#The written language differs. For example most of the languages like English, French, German follow a script that can have inputs from a standard keyboard. But there are other languages like Hindi, Marathi, Sanskrit that follow a script called Devnagri and this cannot be directly typed in from a standard keyboard. So if we have to provide support for these languages we need to support the translation of the characters used in these scripts.&lt;br /&gt;
#The way we write also differs and needs to included in our i18n support. For example most of the languages follow a left-right direction while writing but some languages like Urdu tend to follow a right-left direction.&lt;br /&gt;
#The numbering symbols also vary from language to language. So when we display or accept any text with numbers, we must have i18n to support this mapping.&lt;br /&gt;
#The languages also differ in the use of grammar and structure of the sentences.For example the grammar rules and structure formation in English is way different than the one followed by another language like Sanskrit.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Culture and Writing Conventions:&lt;br /&gt;
&lt;br /&gt;
:Even if the language with the same characters and grammar is used, the use of the language , the symbols , the way of writing and many other things change with change in the region.&lt;br /&gt;
:Following are some of the examples:&lt;br /&gt;
&lt;br /&gt;
#There are some cultures that have some regulations about having a middle name as father’s name but other cultures don’t necessary include the middle name.&lt;br /&gt;
#There might be cases when there are different names or terminologies used in different cultures for the same purpose. For example, to identify a citizen uniquely US has the system of SSN while India is in the process of implementing this by using the term as Aadhar number.&lt;br /&gt;
#Another example of difference in the writing convention can be taken as that of a postal code. Some countries have 6 digit postal codes while others have 5.&lt;br /&gt;
#There is a difference in the use of many other things like the currency(like INR,dollars,Euro) used, the symbols(€,$,₹) used , the units in which the weights , temperature are measured. Another example could be the use of lakhs , crores for mentioning any financial figures in some countries while others use millions, billions.&lt;br /&gt;
#There could also be a difference in the formats used for a same thing. For example the format of writing dates and times vary from one region to another.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* We also have to be careful that we cover all the sensitive topics and issues particular to a language or region.&lt;br /&gt;
&lt;br /&gt;
:Similarly there are many other factors that we need to take care of when we support internationalization for a particular language in a particular region.&lt;br /&gt;
&lt;br /&gt;
= Internationalization in Rails =&lt;br /&gt;
&lt;br /&gt;
:Internationalization support was extended from Rails version 2.2. So in order to internationalize a rails application, it has to be migrated :to Rails 2.2 or above. Every static string in the Rails framework — e.g. Active Record validation messages, time and date formats — have :been internationalized.&lt;br /&gt;
&lt;br /&gt;
:Following needs to be done in order to internationalize a rails application:&lt;br /&gt;
:#Ensure support for internationalization by migrating to appropriate version of rails if needed.&lt;br /&gt;
:#Tell rails where to find the appropriate translations files&lt;br /&gt;
:#Tell rails how to switch locales&lt;br /&gt;
&lt;br /&gt;
::YAML (.yml) or plain Ruby (.rb) files are used for storing translations.&lt;br /&gt;
&lt;br /&gt;
== History ==&lt;br /&gt;
&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100pt&amp;quot;| Ruby 2.2    || Internationalization support was extended from this version of Rails.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 2.3    || Additional feature for Localized Views was added in this version. The view files were rendered with an extension of the locale name.I18n#available_locales and I18n::SimpleBackend#available_locales is available to retrieve an array of available locales.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 3.0    || Some additional features were added to the I18n gem for speed improvements like default translations for attributes,automatic pull for translations on form submit, etc.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 3.1    || I18n namespace lookup support removed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Ways to configure Internationalization in Rails ==&lt;br /&gt;
&lt;br /&gt;
:We can set up a rails application to support internationalization in a number of ways. Below are the various ways to configure our rails application for internationalization.&lt;br /&gt;
&lt;br /&gt;
#'''Configure the I18n module:'''&amp;lt;br&amp;gt;Rails adds all .rb and .yml files from the config/locales directory to your translations load path, automatically. This is the default setting provided by the [https://github.com/svenfuchs/i18n I18n gem]. In order to override this setting we have to make changes in the application.rb files that have instructions on how to add locales from another directory and how to set a different default locale.&lt;br /&gt;
#'''Custom I18n Configuration Setup:'''&amp;lt;br&amp;gt;Optionally, the above code can be placed anywhere in the application preferably in initializers.&lt;br /&gt;
#'''Setting and passing locale:'''&amp;lt;br&amp;gt;The above two steps help setup a default locale throughout the application. But in case we have to provide our application in different languages, we can setup the application default locale in the application.rb and then set the locale using the application-controller.rb before_action. We can then pass the locale we want as a query param for example http://study.com/books?locale=es&lt;br /&gt;
#'''Setting the locale from the domain name:'''&amp;lt;br&amp;gt;Similar to option 3 but instead of passing the locale as a query param, the locale is a part of the domain name itself. Example http://study.es&lt;br /&gt;
::You can implement it like this in your ApplicationController before_action&lt;br /&gt;
#'''Setting the locale from the URL params:'''&amp;lt;br&amp;gt;&lt;br /&gt;
##This can be a tedious task as we have to pass the locale on each request. &lt;br /&gt;
##Rails provides us an alternative for &amp;quot;centralizing dynamic decisions about the URLs&amp;quot; in its ApplicationController#default_url_options and helper methods are dependent on it (by implementing/overriding this method). This will now automatically include the locale param in the query string&lt;br /&gt;
##We can also set the locale in the URL route. For example -http://study.com/es/books .This is achievable by using over-riding default_url_options. You just have to set up your routes with scoping option in routes.rb. &lt;br /&gt;
#'''Setting the locale from client supplied information:'''&amp;lt;br&amp;gt;This can be done in 3 ways&lt;br /&gt;
##Using the default locale of the client browser&lt;br /&gt;
##Using client location to select the locale&lt;br /&gt;
##Saving the users choice of locale as a part of user profile&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Internationalizing Rails application ==&lt;br /&gt;
&lt;br /&gt;
:After your application is prepared for internationalization, we need to use the feature in our application. &lt;br /&gt;
:This can be done in the following ways:&lt;br /&gt;
&lt;br /&gt;
:1.'''Adding Translations:'''&amp;lt;br&amp;gt;In order to internationalize rails code, replace the strings with calls to  the ‘t’ helper.&amp;lt;br&amp;gt;For example: &lt;br /&gt;
:::class HelloWorld &amp;lt;br&amp;gt;def sayHello&amp;lt;br&amp;gt;  puts t(:hello_world)&amp;lt;br&amp;gt;end&amp;lt;br&amp;gt;end&amp;lt;br&amp;gt;or&amp;lt;br&amp;gt;  &amp;lt;%=t :hello_world %&amp;gt;&amp;lt;br&amp;gt;The helper method t also catches missing translations and displays appropriate error message.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;nowiki /&amp;gt;# config/locales/en.yml&amp;lt;br&amp;gt;en:&amp;lt;br&amp;gt; hello_world: Hello world!&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;nowiki /&amp;gt;# config/locales/es.yml&amp;lt;br&amp;gt;es:&amp;lt;br&amp;gt;hello_world: hola mundo&lt;br /&gt;
&lt;br /&gt;
:2.'''Passing variables to translation:'''&amp;lt;br&amp;gt;You can use variables in the translation messages and pass their values from the view.&amp;lt;br&amp;gt;&lt;br /&gt;
::en:&amp;lt;br&amp;gt;portal: &amp;quot;Mypack&amp;quot;&amp;lt;br&amp;gt;university:&amp;lt;br&amp;gt;ncsu:&amp;lt;br&amp;gt;description: ! 'NCSU student information is accessed on %{portal_name}’&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;t('.description', portal_name: t(‘portal’))&lt;br /&gt;
&lt;br /&gt;
:3.Adding date/ time formats:&lt;br /&gt;
::OK! Now let's add a timestamp to the view, so we can demo the date/time localization feature as well. To localize the time format you pass the Time object to I18n.l or (preferably) use ‘l’ helper. You can pick a format by passing the :format option — by default the :default format is used.&lt;br /&gt;
::In the view file:&lt;br /&gt;
&amp;lt;p&amp;gt;&amp;lt;%= l Time.now, format: :short %&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt;
In the yml file:&lt;br /&gt;
es:&lt;br /&gt;
  time:&lt;br /&gt;
    formats:&lt;br /&gt;
      short: &amp;quot; Son las %H&amp;quot;&lt;br /&gt;
&lt;br /&gt;
4.	Inflection rules for locales other than english&lt;br /&gt;
Rails 4.0 provides a feature to define inflection rules (singularization and pluralization)  in config/initializers/inflections.rb. &lt;br /&gt;
&lt;br /&gt;
5.	Localized views&lt;br /&gt;
For static websites available in different languages or for large static content, localized views is a useful feature. This feature enables having separate view file for different locales. For example for default locale we can have show.html.erb file while for Spanish we can have show.es.html.erb. Thus we don’t need to maintain long .yml files for each supported locale for long static pages.&lt;/div&gt;</summary>
		<author><name>Srparadk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w18_bs&amp;diff=76075</id>
		<title>CSC/ECE 517 Fall 2013/ch1 1w18 bs</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w18_bs&amp;diff=76075"/>
		<updated>2013-09-16T20:35:04Z</updated>

		<summary type="html">&lt;p&gt;Srparadk: /* Internationalizing Rails application */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Internationalization in Rails&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
:In general when we start a conversation, the first default language of communication we use is English, but if the other person is not familiar with English we try and translate our dialogue in a language that the person is familiar with. Similarly whenever we write a program or a document we write it in English by default. But what if someone who is not familiar with English wants to read your program or code? The simple solution is that we translate program or code into a language that the person is familiar with. And for this, we use a term called internationalization.&lt;br /&gt;
&lt;br /&gt;
:Internationalization is a way by which we can view an application in various languages without actually making changes to the code of the application. This saves us a lot of time and effort, as we don’t have to write or edit the same code or document in all the copies.&lt;br /&gt;
&lt;br /&gt;
:Internationalization has an acronym, rather more of a numeronym ,which is i18n where the number 18 represents the number of letters between the first and last letters in the word internationalization.&lt;br /&gt;
&lt;br /&gt;
== Aspects to consider in Internationalization ==&lt;br /&gt;
&lt;br /&gt;
:Now when we are to change our application according to a particular language or a region , we need to keep in mind numerous points that are important, implicit, particular or sensitive to that language or region. Like for example when we take a language into consideration for which our application needs to be translated, we need to consider the spoken and written aspects of that language. Also, there might be a case when we have the same language but it differs from one region to other. For this we need to keep in mind the typical change in the use of words, grammar and symbol for each region that uses the same language. Our application must also provide support for the varied writing conventions that differ from a language to another language or from one region to another.&lt;br /&gt;
&lt;br /&gt;
:Below are the examples of the points we need to keep in mind while we provide internationalization to our application :&lt;br /&gt;
&lt;br /&gt;
* Language :&lt;br /&gt;
&lt;br /&gt;
:Here the i18n support to an application needs to provide the character encoding keeping in mind the following points:&lt;br /&gt;
&lt;br /&gt;
#The written language differs. For example most of the languages like English, French, German follow a script that can have inputs from a standard keyboard. But there are other languages like Hindi, Marathi, Sanskrit that follow a script called Devnagri and this cannot be directly typed in from a standard keyboard. So if we have to provide support for these languages we need to support the translation of the characters used in these scripts.&lt;br /&gt;
#The way we write also differs and needs to included in our i18n support. For example most of the languages follow a left-right direction while writing but some languages like Urdu tend to follow a right-left direction.&lt;br /&gt;
#The numbering symbols also vary from language to language. So when we display or accept any text with numbers, we must have i18n to support this mapping.&lt;br /&gt;
#The languages also differ in the use of grammar and structure of the sentences.For example the grammar rules and structure formation in English is way different than the one followed by another language like Sanskrit.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Culture and Writing Conventions:&lt;br /&gt;
&lt;br /&gt;
:Even if the language with the same characters and grammar is used, the use of the language , the symbols , the way of writing and many other things change with change in the region.&lt;br /&gt;
:Following are some of the examples:&lt;br /&gt;
&lt;br /&gt;
#There are some cultures that have some regulations about having a middle name as father’s name but other cultures don’t necessary include the middle name.&lt;br /&gt;
#There might be cases when there are different names or terminologies used in different cultures for the same purpose. For example, to identify a citizen uniquely US has the system of SSN while India is in the process of implementing this by using the term as Aadhar number.&lt;br /&gt;
#Another example of difference in the writing convention can be taken as that of a postal code. Some countries have 6 digit postal codes while others have 5.&lt;br /&gt;
#There is a difference in the use of many other things like the currency(like INR,dollars,Euro) used, the symbols(€,$,₹) used , the units in which the weights , temperature are measured. Another example could be the use of lakhs , crores for mentioning any financial figures in some countries while others use millions, billions.&lt;br /&gt;
#There could also be a difference in the formats used for a same thing. For example the format of writing dates and times vary from one region to another.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* We also have to be careful that we cover all the sensitive topics and issues particular to a language or region.&lt;br /&gt;
&lt;br /&gt;
:Similarly there are many other factors that we need to take care of when we support internationalization for a particular language in a particular region.&lt;br /&gt;
&lt;br /&gt;
= Internationalization in Rails =&lt;br /&gt;
&lt;br /&gt;
:Internationalization support was extended from Rails version 2.2. So in order to internationalize a rails application, it has to be migrated :to Rails 2.2 or above. Every static string in the Rails framework — e.g. Active Record validation messages, time and date formats — have :been internationalized.&lt;br /&gt;
&lt;br /&gt;
:Following needs to be done in order to internationalize a rails application:&lt;br /&gt;
:#Ensure support for internationalization by migrating to appropriate version of rails if needed.&lt;br /&gt;
:#Tell rails where to find the appropriate translations files&lt;br /&gt;
:#Tell rails how to switch locales&lt;br /&gt;
&lt;br /&gt;
::YAML (.yml) or plain Ruby (.rb) files are used for storing translations.&lt;br /&gt;
&lt;br /&gt;
== History ==&lt;br /&gt;
&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100pt&amp;quot;| Ruby 2.2    || Internationalization support was extended from this version of Rails.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 2.3    || Additional feature for Localized Views was added in this version. The view files were rendered with an extension of the locale name.I18n#available_locales and I18n::SimpleBackend#available_locales is available to retrieve an array of available locales.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 3.0    || Some additional features were added to the I18n gem for speed improvements like default translations for attributes,automatic pull for translations on form submit, etc.&lt;br /&gt;
|-&lt;br /&gt;
| Ruby 3.1    || I18n namespace lookup support removed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Ways to configure Internationalization in Rails ==&lt;br /&gt;
&lt;br /&gt;
:We can set up a rails application to support internationalization in a number of ways. Below are the various ways to configure our rails application for internationalization.&lt;br /&gt;
&lt;br /&gt;
#'''Configure the I18n module:'''&amp;lt;br&amp;gt;Rails adds all .rb and .yml files from the config/locales directory to your translations load path, automatically. This is the default setting provided by the [https://github.com/svenfuchs/i18n I18n gem]. In order to override this setting we have to make changes in the application.rb files that have instructions on how to add locales from another directory and how to set a different default locale.&lt;br /&gt;
#'''Custom I18n Configuration Setup:'''&amp;lt;br&amp;gt;Optionally, the above code can be placed anywhere in the application preferably in initializers.&lt;br /&gt;
#'''Setting and passing locale:'''&amp;lt;br&amp;gt;The above two steps help setup a default locale throughout the application. But in case we have to provide our application in different languages, we can setup the application default locale in the application.rb and then set the locale using the application-controller.rb before_action. We can then pass the locale we want as a query param for example http://study.com/books?locale=es&lt;br /&gt;
#'''Setting the locale from the domain name:'''&amp;lt;br&amp;gt;Similar to option 3 but instead of passing the locale as a query param, the locale is a part of the domain name itself. Example http://study.es&lt;br /&gt;
::You can implement it like this in your ApplicationController before_action&lt;br /&gt;
#'''Setting the locale from the URL params:'''&amp;lt;br&amp;gt;&lt;br /&gt;
##This can be a tedious task as we have to pass the locale on each request. &lt;br /&gt;
##Rails provides us an alternative for &amp;quot;centralizing dynamic decisions about the URLs&amp;quot; in its ApplicationController#default_url_options and helper methods are dependent on it (by implementing/overriding this method). This will now automatically include the locale param in the query string&lt;br /&gt;
##We can also set the locale in the URL route. For example -http://study.com/es/books .This is achievable by using over-riding default_url_options. You just have to set up your routes with scoping option in routes.rb. &lt;br /&gt;
#'''Setting the locale from client supplied information:'''&amp;lt;br&amp;gt;This can be done in 3 ways&lt;br /&gt;
##Using the default locale of the client browser&lt;br /&gt;
##Using client location to select the locale&lt;br /&gt;
##Saving the users choice of locale as a part of user profile&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Internationalizing Rails application ==&lt;br /&gt;
&lt;br /&gt;
:After your application is prepared for internationalization, we need to use the feature in our application. &lt;br /&gt;
:This can be done in the following ways:&lt;br /&gt;
&lt;br /&gt;
:1.'''Adding Translations:'''&amp;lt;br&amp;gt;In order to internationalize rails code, replace the strings with calls to  the ‘t’ helper.&amp;lt;br&amp;gt;For example: &lt;br /&gt;
:::class HelloWorld &amp;lt;br&amp;gt;def sayHello&amp;lt;br&amp;gt;  puts t(:hello_world)&amp;lt;br&amp;gt;end&amp;lt;br&amp;gt;end&amp;lt;br&amp;gt;or&amp;lt;br&amp;gt;  &amp;lt;%=t :hello_world %&amp;gt;&amp;lt;br&amp;gt;The helper method t also catches missing translations and displays appropriate error message.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;nowiki /&amp;gt;# config/locales/en.yml&amp;lt;br&amp;gt;en:&amp;lt;br&amp;gt; hello_world: Hello world!&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;nowiki /&amp;gt;# config/locales/es.yml&amp;lt;br&amp;gt;es:&amp;lt;br&amp;gt;hello_world: hola mundo&lt;br /&gt;
&lt;br /&gt;
:2.'''Passing variables to translation:'''&amp;lt;br&amp;gt;You can use variables in the translation messages and pass their values from the view.&amp;lt;br&amp;gt;&lt;br /&gt;
::en:&amp;lt;br&amp;gt;portal: &amp;quot;Mypack&amp;quot;&amp;lt;br&amp;gt;university:&amp;lt;br&amp;gt;ncsu:&amp;lt;br&amp;gt;description: ! 'NCSU student information is accessed on %{portal_name}’&amp;lt;br&amp;gt;t('.description', portal_name: t(‘portal’))&lt;br /&gt;
&lt;br /&gt;
3.	Adding date/ time formats:&lt;br /&gt;
OK! Now let's add a timestamp to the view, so we can demo the date/time localization feature as well. To localize the time format you pass the Time object to I18n.l or (preferably) use ‘l’ helper. You can pick a format by passing the :format option — by default the :default format is used.&lt;br /&gt;
In the view file:&lt;br /&gt;
&amp;lt;p&amp;gt;&amp;lt;%= l Time.now, format: :short %&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt;
In the yml file:&lt;br /&gt;
es:&lt;br /&gt;
  time:&lt;br /&gt;
    formats:&lt;br /&gt;
      short: &amp;quot; Son las %H&amp;quot;&lt;br /&gt;
&lt;br /&gt;
4.	Inflection rules for locales other than english&lt;br /&gt;
Rails 4.0 provides a feature to define inflection rules (singularization and pluralization)  in config/initializers/inflections.rb. &lt;br /&gt;
&lt;br /&gt;
5.	Localized views&lt;br /&gt;
For static websites available in different languages or for large static content, localized views is a useful feature. This feature enables having separate view file for different locales. For example for default locale we can have show.html.erb file while for Spanish we can have show.es.html.erb. Thus we don’t need to maintain long .yml files for each supported locale for long static pages.&lt;/div&gt;</summary>
		<author><name>Srparadk</name></author>
	</entry>
</feed>