<?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=Ajulka</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=Ajulka"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Ajulka"/>
	<updated>2026-08-13T17:51:41Z</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_2021_-_E2159._Expertiza_internationalization&amp;diff=142386</id>
		<title>CSC/ECE 517 Fall 2021 - E2159. Expertiza internationalization</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization&amp;diff=142386"/>
		<updated>2021-11-30T06:44:58Z</updated>

		<summary type="html">&lt;p&gt;Ajulka: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Important Links ==&lt;br /&gt;
*Git PR - https://github.com/expertiza/expertiza/pull/2151&lt;br /&gt;
*Git beta branch - https://github.com/arnavjulka/expertiza/tree/beta&lt;br /&gt;
*Overall Video - https://drive.google.com/file/d/1dc9St9J77q-Mb_vRuYBg4vs9Xv0SHm4d/view?usp=sharing&lt;br /&gt;
*Testing Video - https://drive.google.com/file/d/1TOatjhe0wzxTpmWDuC_ryVFmtQ-X7FJq/view?usp=sharing&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Introduction - Purpose &amp;amp; Problem ==&lt;br /&gt;
&lt;br /&gt;
Currently, all Expertiza screens can only be viewed in English. Many Expertiza users are from other countries. This is a problem since this limits the accessibility of Expertiza. An important step in solving this problem is by making Expertiza available in more languages, which is a form of internationalization.&lt;br /&gt;
W3C defines [https://www.w3.org/International/questions/qa-i18n internationalization] as “''the design and development of a product, application or document content that enables easy localization for target audiences that vary in culture, region, or language.''”&lt;br /&gt;
&lt;br /&gt;
[[File:country_pie.png|none|500px|]]&amp;lt;br&amp;gt;&lt;br /&gt;
Survey of home country of Expertiza users for a given course&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Scope:''' The scope of this project is limited however only to static strings. i.e. user-generated content will not be automatically translated to other languages.&lt;br /&gt;
&lt;br /&gt;
'''Breaking down internationalization into 3 sequential subproblems:'''&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Twophase2.jpg|none|700px]]&amp;lt;br&amp;gt;&lt;br /&gt;
'''1. Language selection'''&amp;lt;br&amp;gt;&lt;br /&gt;
Every user has an option to set a language preference in the User Profile Information Edit page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:ProfileEditPage.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
There is also an option where the instructor can choose a default language for a course. &lt;br /&gt;
&lt;br /&gt;
[[File:language2inter.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Thus, the language not only varies from user to user but also across screens for the same user. Thus we need to recompute the language in which the page is to be rendered. If the student has given a language preference, then the choice is given weightage over the course default language chosen by the instructor. &lt;br /&gt;
&lt;br /&gt;
'''2. Rendering the language'''&amp;lt;br&amp;gt;&lt;br /&gt;
'''How do we go about rendering the screen in that language?''' &amp;lt;br&amp;gt;&lt;br /&gt;
In the previous step, we’ve identified the language in which a view is to be rendered. It is important to note that this language may not only differ for a different user, but also for a different page for the same user. The question now becomes, how do we render the screen in this language?&amp;lt;br&amp;gt;&lt;br /&gt;
To tackle this question, we explore 2 fundamental concepts:&amp;lt;br&amp;gt;&lt;br /&gt;
'''2.1 Views are composed of independent language elements'''&amp;lt;br&amp;gt;&lt;br /&gt;
While this is something we typically take for granted, it becomes especially important in the context of translation. That is, a view is not a single contiguous block of text, nor is it an atomic visualization of information (unlike a screenshot), but rather a carefully organized collection of individual elements such as texts, buttons, etc that each contain language that needs to be translated separately. Crucially, this means that we cannot swap out a page in one language in its entirety for a page in another language in its entirety. Instead, each individual element needs to be swapped out individually so as to only impact the language and not the structural composition of the page itself.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''2.2 Views require translation at a large number of call sites'''&amp;lt;br&amp;gt;&lt;br /&gt;
Given that a view is composed of individual elements, this also means that the computation of how to translate such an element such as a button’s text would need to be done separately for each element. This would result in not only a single centralized &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''3. Translation gaps'''&lt;br /&gt;
&lt;br /&gt;
What if the translation for the target language is not available?&lt;br /&gt;
Even translation for a language like Hindi may be available in general, the translation for a given text may not be available Hindi. This may be due to a variety of reasons:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
The specific text may have been accidentally missed out (remember the translation is not being done at runtime through an API, but rather curated by the developer)&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
The given text is non-trivial to translate to the target language&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
Our design would thus need to accommodate this by seamlessly falling back on another language whose translation is available.&lt;br /&gt;
&lt;br /&gt;
== Scope ==&lt;br /&gt;
The scope of this project is limited however only to static strings. I.e. user-generated content will not be automatically translated to other languages.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
'''Proposed Solution''' &amp;lt;br&amp;gt;&lt;br /&gt;
We explore and solve each of the three problems above in isolation:&lt;br /&gt;
&lt;br /&gt;
'''''1. Language selection'''''&amp;lt;br&amp;gt;&lt;br /&gt;
The language in which the page is rendered depends on a set of conditions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;If the user has set a language preference all pages are displayed in that language.&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;If the user has not set a language preference and the user is an instructor, all the pages are displayed in English.&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;If the user has not set a language preference and the user is a student who is on a page that is specific to a course for which the instructor has added a default language, the page is displayed in the course’s default language.&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The below functions are added and called before page rendering to bring in this logic.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  before_action :set_locale&lt;br /&gt;
&lt;br /&gt;
  def set_locale&lt;br /&gt;
    # Checks whether the user is logged in, else the default locale is used&lt;br /&gt;
    if logged_in?&lt;br /&gt;
      # If the current user has set his preferred language, the locale is set according to their preference&lt;br /&gt;
      if @current_user.locale != &amp;quot;no_pref&amp;quot;&lt;br /&gt;
        I18n.locale = @current_user.locale&lt;br /&gt;
        # If the user doesn't have any preference, the locale is taken from the course locale, if the current page is a course specific page or else default locale is used&lt;br /&gt;
      elsif current_user_role? &amp;amp;&amp;amp; current_user_role.student? &amp;amp;&amp;amp; [&amp;quot;student_task&amp;quot;, &amp;quot;sign_up_sheet&amp;quot;, &amp;quot;student_teams&amp;quot;, &amp;quot;student_review&amp;quot;, &amp;quot;grades&amp;quot;, &amp;quot;submitted_content&amp;quot;, &amp;quot;participants&amp;quot;].include?(params[:controller])&lt;br /&gt;
        set_new_locale_for_student&lt;br /&gt;
      else&lt;br /&gt;
        I18n.locale = I18n.default_locale&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      I18n.locale = I18n.default_locale&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def set_new_locale_for_student&lt;br /&gt;
    # Gets participant using student from params&lt;br /&gt;
    if !params[:id].nil? || !params[:student_id].nil?&lt;br /&gt;
      participant_id = params[:id] || params[:student_id]&lt;br /&gt;
      participant = AssignmentParticipant.find_by(id: participant_id)&lt;br /&gt;
      # If id or student_id not correct, revert to locale based on courses.&lt;br /&gt;
      if participant.nil?&lt;br /&gt;
        find_locale_from_courses&lt;br /&gt;
        return&lt;br /&gt;
      end&lt;br /&gt;
      # Find assignment from participant and find locale from the assigment&lt;br /&gt;
      assignment = participant.assignment&lt;br /&gt;
      if !assignment.course.nil?&lt;br /&gt;
        new_locale = assignment.course.locale&lt;br /&gt;
        if !new_locale.nil?&lt;br /&gt;
          I18n.locale = new_locale&lt;br /&gt;
        else&lt;br /&gt;
          I18n.locale = I18n.default_locale&lt;br /&gt;
        end&lt;br /&gt;
      else&lt;br /&gt;
        I18n.locale = I18n.default_locale&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      find_locale_from_courses&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def find_locale_from_courses&lt;br /&gt;
    # If the page is a course or assignment page with no specific student id, every course of that student is checked and if&lt;br /&gt;
    # the language for all these course are same, the page is displayed in that language&lt;br /&gt;
  courseParticipants = CourseParticipant.where(user_id: current_user.id)&lt;br /&gt;
    courseParticipantsLocales = courseParticipants.map { |cp| cp.course.locale }&lt;br /&gt;
    # If no tasks, then possible to have no courses assigned.&lt;br /&gt;
    if courseParticipantsLocales.uniq.length == 1 #&amp;amp;&amp;amp; !@tasks.empty?&lt;br /&gt;
      course = courseParticipants.first.course&lt;br /&gt;
      if course.locale?&lt;br /&gt;
        I18n.locale = course.locale&lt;br /&gt;
      else&lt;br /&gt;
        I18n.locale = I18n.default_locale&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      I18n.locale = I18n.default_locale&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;If the student user has not set a language preference and is not on a course-specific page, then the page is displayed in English.&lt;br /&gt;
If a language preference is obtained by following the above conditions but some keys in the page don't have a translation for the language, the English translation for that key is returned as a fallback.&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''''2. Rendering the language'''''&amp;lt;br&amp;gt;&lt;br /&gt;
Once we have determined the language in which to render the page, we now need to update the rails view code to actually generate the appropriate HTML in the target language. This is the responsibility of the view. However, currently, the actual content of the HTML is hardcoded in (red) English. For example:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;Summary Report for assignment: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;Team: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
As discussed earlier, “Views are composed of independent language elements” and so we cannot simply swap out the entire page content for a separate page in another language (Why? - See “swap out the entire view” in the alternative approaches section):&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;Rapport de synthèse pour l'affectation: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;Équipe: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;Instead, the better approach is to have a single unified view that dynamically changes based on the selected language:&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;&amp;lt;%=language==’en’ ? ‘Summary Report for assignment’ : ‘Rapport de synthèse pour l'affectation’&amp;gt;: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;&amp;lt;%=language==’en’ ? ‘Team’ : ‘Équipe’&amp;gt;: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;However this is clearly infeasible considering the number of call sites where we have to apply this logic. Thus, in order to maximize how concise the call site is, we can pull out this logic into a common helper function:&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;&amp;lt;%=localized(“report_summary.page_header”)&amp;gt;: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;&amp;lt;%=localized(“report_summary.team_label”)&amp;gt;: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;Here the assumption is that the localized(“key”) is aware of the currently selected language and that “report_summary.page_header” is the key for the header which is available in English and Hindi. The helper intelligently selects and returns the right text based on the currently selected language. Through this approach, we are able to render the view in multiple possible languages without any significant increase in the verbosity of the view.&lt;br /&gt;
&lt;br /&gt;
What’s more, is that the above problem is a common problem for user-facing applications and a standard library for doing the above and much more already exists for rails applications called i18n&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''''I18n - Internationalisation, How are we using I18n in Ruby on Rail'''''&amp;lt;br&amp;gt;&lt;br /&gt;
I18n is a ruby library/gem which helps us render the static string on the view dynamically. Dynamicity means that based on a local decision of choosing the current language of the view, the library returns the strings of that particular language at runtime.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
These strings, instead of hardcoding in the view.rb, are provided in external .yml files. Now at the View level, we can pass an id to the 't' function and the I18n library returns the string for that id of the current set language(called as locale). &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:i18n.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
For this purpose, we have to provide .yml files for each language and in those language-specific .yml, we have to provide a map of key-value pairs where the key is the id of the string and value is the string in that particular language. By default the language or locale is set to be English(:en). &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
THE GREATEST BENEFITS of using this library are - &amp;lt;br&amp;gt;&lt;br /&gt;
*The strings aren't hardcoded in the code/build. The strings are being fetched from external files which can be easily modified. For example, if one needs to change the text from 'Please Help' to 'Help', then one just needs to make a change in the .yml file and the change would reflect on the browser. For this change, we didn't need to redeploy the server. We just Decoupled the view when and where from what content is to be shown. &lt;br /&gt;
*Adding more languages is now super easy. Adding support for another language is just one line change in the config and adding a .yml file (having all the key-value pairs for the strings) for the new language. By doing this we can extend the language support as much as we want.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''''3. Translation gaps'''''&lt;br /&gt;
&amp;lt;br&amp;gt;Also, if the language is set to be Hindi or any other language but the key-value pair is not set for that particular string then, automatically the library returns the default which is the English text.&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;config.i18n.fallbacks = [:en]&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Alternate approaches ==&lt;br /&gt;
&lt;br /&gt;
'''1. Why not simply swap out the entire view for another language instead of each text?'''&amp;lt;br&amp;gt;&lt;br /&gt;
A view is an organized collection of multiple separate elements, views often involve dynamic generation and some level of sophistication. If we were to swap out one page in its entirety for another page this would often violate the '''DRY''' principle since we would have to have two separate implementations of the view in each language. Thus in the worst case, you have a complex view that has to be replicated dozens of times in various languages.&lt;br /&gt;
The majority of complexity of the page is not in the content itself but rather the code that executes to generate that content, thus it makes sense to instead maintain a single view and embed the language switching logic at each location where translation needs to occur to avoid replication of everything around it.&lt;br /&gt;
&lt;br /&gt;
'''2. Why did we pick i18n over implementing it ourselves?'''&amp;lt;br&amp;gt;&lt;br /&gt;
Doing it ourselves felt like a great option. But i18n not just selects a language string at runtime for us it does a lot more under the hood which makes our lives easier. For example, it manages locale over the session for us, even if we change the urls and shift tabs and other stuff it manages our locale. &amp;lt;br&amp;gt;&lt;br /&gt;
Also there is a great principle that says - “ If it isn’t broken, Don’t fix it”. The library manages the registering of different language yml files, points to the right right text at runtime, manages session locale and a lot more. So we want to explore this library instead of reimplementing the same thing again.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''3, Why did we store the default language choices in database instead of in session?'''&amp;lt;br&amp;gt;&lt;br /&gt;
We had to decide on whether to keep the student’s language preference in the database or in the session. We have thought about both approaches and below listed are the advantages and disadvantages.&lt;br /&gt;
&lt;br /&gt;
In the work done by the previous team, they added a dropdown in the navbar where a student can choose the preferred language. One of the changes that we did was to move this field to the user profile page. The earlier team used session storage to store the preferred language. This session resets on every logout, but since the preferred language can easily be set from any page this wasn't much of an issue.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Storing user language preference in database.&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	If we are moving the language preference field to the user profile page, it will create some user experience issues if the preference is stored in session. The student will have to visit the user profile page every time they log in. To avoid this scenario, it’s better to keep the language preference in the database, so that the preference stays saved across sessions.&lt;br /&gt;
	The disadvantage of moving the language preference to the database is that it brings forth a schema change and this always requires a very careful going through to ensure that nothing else is affected. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Storing language preference in session storage.&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The main advantage of storing the language preference in session storage is that no schema change is involved. This decreases the chance of other features being affected. The main disadvantage is that the student will have to go to the user profile page every time they log in to set the preference, causing a user experience issue. Keep in mind that we’re moving the field away from the navbar to a user profile page.&lt;br /&gt;
&lt;br /&gt;
After considering these points, we finally decided to go store the user preference in the database itself as the project requires us to add a language preference field in user profile page.&lt;br /&gt;
&lt;br /&gt;
== Use Case Diagram ==&lt;br /&gt;
&amp;lt;li&amp;gt;An instructor can add a default language to any course. English is the default choice.&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;The user has an option to change their preferred language at any time. They have the option to do so in their profile page. &amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;All pages including the course-related and non-course-related pages are displayed in the user preferred language for any user other than student&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Every non-course-related page is displayed in the student’s preferred language. Keys for which a translation is not found are displayed in the default language that is English&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Every course-related page is displayed in the student’s preferred language. If the student doesn’t have a preferred language, the course is displayed in the course’s preferred language. Keys for which a translation is not found are displayed in the default language that is English.&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:usecasediagram.png|2000px|865px]]&lt;br /&gt;
&lt;br /&gt;
== Major design patterns and principles used ==&lt;br /&gt;
&lt;br /&gt;
'''1. DRY: The i18n ‘t’ function'''&amp;lt;br&amp;gt;&lt;br /&gt;
We observe an extreme case of DRY with the t function of i18n.&lt;br /&gt;
For some background, the t function of the library takes in a key representing a text and returns the content referred to by that key in the preferred language of the user. It also performs many other functions such as falling back to a backup language if the translation for the preferred language has not been configured for that specific key. Thus since this logic has to be applied at every element of the view, it would behove us to extract this logic into a reusable function which is what the designers of the i18n library have employed&lt;br /&gt;
&lt;br /&gt;
'''2. Chain of responsibility'''&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Chainofresp.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The I18n library gives us an option to have many fall back options. When the required text for a given language is not found, we then move on to find the text for the next language in the chain and so on until we find it. And in the end we will put english as default language. So if the key value pair for the text is not found in none of the yml files then the text will be fetched from the English language yml file.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''3. Open closed principle &amp;amp; Strategy Pattern'''&amp;lt;br&amp;gt;&lt;br /&gt;
As discussed in the “Language selection&amp;quot; design proposal above, if the user has not selected a preferred language, we do not simply default the view to render in the application language (English). Instead, the project requirements state that for course specific screens such as the assignment view, we would need to render the view in the course’s language.&lt;br /&gt;
While we could implement this code into the application controller that checks the controller being access and accordingly applies overrides on the default language, this violates the open closed principle since we would need to extend this logic any time we introduce a new course specific screen. Instead a better approach is to delegate the decision of selecting the language to the view itself since the view would be most aware of whether the view is course specific or not. We can also preserve the DRYness through mix-ins.&lt;br /&gt;
&lt;br /&gt;
== Database Design ==&lt;br /&gt;
We add the locale field to the users and courses tables which has the default values 0 and 1, which is no preference and en_US respectively.&lt;br /&gt;
&lt;br /&gt;
The migrations will look as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class AddLangLocaleToUsers &amp;lt; ActiveRecord::Migration&lt;br /&gt;
  def change&lt;br /&gt;
    add_column :users, :locale, :integer, default: 0&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class AddLocaleToCourses &amp;lt; ActiveRecord::Migration&lt;br /&gt;
  def change&lt;br /&gt;
    add_column :courses, :locale, :integer, default: 1&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Database Modification ==&lt;br /&gt;
We add a new integer field to the users table to store the user preferred language. The integer will be hashed to the supported languages. The default value in the table will be 0, which will be no_pref.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
enum locale: {&lt;br /&gt;
      no_pref: 0,&lt;br /&gt;
      en_US: 1,&lt;br /&gt;
      hi_IN: 2&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We also add a new integer field to the courses table to store the course preferred language. The integer will be hashed to the supported languages. The default value in the table will be 1, which will be en_US.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
enum locale: {&lt;br /&gt;
      en_US: 1,&lt;br /&gt;
      hi_IN: 2&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Hence the updated courses table will look like following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
create_table &amp;quot;courses&amp;quot;, force: :cascade do |t|&lt;br /&gt;
    t.string   &amp;quot;name&amp;quot;,            limit: 255&lt;br /&gt;
    t.integer  &amp;quot;instructor_id&amp;quot;,   limit: 4&lt;br /&gt;
    t.string   &amp;quot;directory_path&amp;quot;,  limit: 255&lt;br /&gt;
    t.text     &amp;quot;info&amp;quot;,            limit: 65535&lt;br /&gt;
    t.datetime &amp;quot;created_at&amp;quot;&lt;br /&gt;
    t.datetime &amp;quot;updated_at&amp;quot;&lt;br /&gt;
    t.boolean  &amp;quot;private&amp;quot;,                       default: false, null: false&lt;br /&gt;
    t.integer  &amp;quot;institutions_id&amp;quot;, limit: 4&lt;br /&gt;
    t.integer  &amp;quot;locale&amp;quot;,          limit: 4,     default: 1&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
While the updated users table will look like the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
create_table &amp;quot;users&amp;quot;, force: :cascade do |t|&lt;br /&gt;
    t.string  &amp;quot;name&amp;quot;,                      limit: 255,      default: &amp;quot;&amp;quot;,    null: false&lt;br /&gt;
    t.string  &amp;quot;crypted_password&amp;quot;,          limit: 40,       default: &amp;quot;&amp;quot;,    null: false&lt;br /&gt;
    t.integer &amp;quot;role_id&amp;quot;,                   limit: 4,        default: 0,     null: false&lt;br /&gt;
    t.string  &amp;quot;password_salt&amp;quot;,             limit: 255&lt;br /&gt;
    t.string  &amp;quot;fullname&amp;quot;,                  limit: 255&lt;br /&gt;
    t.string  &amp;quot;email&amp;quot;,                     limit: 255&lt;br /&gt;
    t.integer &amp;quot;parent_id&amp;quot;,                 limit: 4&lt;br /&gt;
    t.boolean &amp;quot;private_by_default&amp;quot;,                         default: false&lt;br /&gt;
    t.string  &amp;quot;mru_directory_path&amp;quot;,        limit: 128&lt;br /&gt;
    t.boolean &amp;quot;email_on_review&amp;quot;&lt;br /&gt;
    t.boolean &amp;quot;email_on_submission&amp;quot;&lt;br /&gt;
    t.boolean &amp;quot;email_on_review_of_review&amp;quot;&lt;br /&gt;
    t.boolean &amp;quot;is_new_user&amp;quot;,                                default: true,  null: false&lt;br /&gt;
    t.integer &amp;quot;master_permission_granted&amp;quot;, limit: 1,        default: 0&lt;br /&gt;
    t.string  &amp;quot;handle&amp;quot;,                    limit: 255&lt;br /&gt;
    t.text    &amp;quot;digital_certificate&amp;quot;,       limit: 16777215&lt;br /&gt;
    t.string  &amp;quot;persistence_token&amp;quot;,         limit: 255&lt;br /&gt;
    t.string  &amp;quot;timezonepref&amp;quot;,              limit: 255&lt;br /&gt;
    t.text    &amp;quot;public_key&amp;quot;,                limit: 16777215&lt;br /&gt;
    t.boolean &amp;quot;copy_of_emails&amp;quot;,                             default: false&lt;br /&gt;
    t.integer &amp;quot;institution_id&amp;quot;,            limit: 4&lt;br /&gt;
    t.boolean &amp;quot;preference_home_flag&amp;quot;,                       default: true&lt;br /&gt;
    t.integer &amp;quot;locale&amp;quot;,                    limit: 4,        default: 0&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The locale field is the last column on both tables:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    courses:&amp;gt; t.integer  &amp;quot;locale&amp;quot;,  limit: 4,    default: 1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
      users:&amp;gt; t.integer &amp;quot;locale&amp;quot;,   limit: 4,    default: 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
===Manual Testing===&lt;br /&gt;
&lt;br /&gt;
Through manual testing, we aim to identify if all the features of the application are working as intended when the language conversion occurs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Scenario 1&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Log in to Expertiza as a student.&lt;br /&gt;
&lt;br /&gt;
2. Go to the “User Profile Information” page and change “Preferred Language” to Hindi.&lt;br /&gt;
&lt;br /&gt;
3. Check to see if the English strings on the profile page are translated to Hindi.&lt;br /&gt;
&lt;br /&gt;
4. Check if a page for which Hindi translation keys are added has its English static strings translated to Hindi.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Scenario 2&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Log in to Expertiza as a student.&lt;br /&gt;
&lt;br /&gt;
2. Go to the “User Profile Information” page and change “Preferred Language” to No Preferences.&lt;br /&gt;
&lt;br /&gt;
3.  Check to see if the English strings on the page are unchanged, as the “User Profile Information” translates only if the student has a preference.&lt;br /&gt;
&lt;br /&gt;
4. Go to an assignment page for which Hindi translation keys are added, which is under a course with the default language set to Hindi, and check whether the English strings are translated to Hindi.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Scenario 3&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Log in to Expertiza as a student.&lt;br /&gt;
&lt;br /&gt;
2. Go to the “User Profile Information” page and change “Preferred Language” to Nil.&lt;br /&gt;
&lt;br /&gt;
3.  Check to see if the English strings on the page are unchanged, as the “User Profile Information” translates only if the student has a preference.&lt;br /&gt;
&lt;br /&gt;
4. Go to a non-course-specific page and verify that the page is displayed in English itself, as non of the default languages set for any of the courses should have any role.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Scenario 4&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Log in to Expertiza as a student.&lt;br /&gt;
&lt;br /&gt;
2. Go to the “User Profile Information” page and change “Preferred Language” to Hindi.&lt;br /&gt;
&lt;br /&gt;
3.  Go to a page where translation keys aren’t added completely and make sure that the unspecified keys display strings in English as a fallback.&lt;br /&gt;
&lt;br /&gt;
===Automated Testing===&lt;br /&gt;
Testing Video - https://drive.google.com/file/d/1TOatjhe0wzxTpmWDuC_ryVFmtQ-X7FJq/view?usp=sharing&lt;br /&gt;
&lt;br /&gt;
== Future Scope==&lt;br /&gt;
'''1. Expand to more languages'''&amp;lt;br&amp;gt;&lt;br /&gt;
As part of this project we have targetted Hindi as a second language, however our work makes it easy to extend to other languages as well.&lt;br /&gt;
&lt;br /&gt;
'''2. Identify and implement the course language override on more course specific screens'''&amp;lt;br&amp;gt;&lt;br /&gt;
As part of this project, we have introduced a generic framework by which any view can provide a preferred language in which it should be rendered, this is required by this project for the course language feature set by the instructor.&lt;br /&gt;
We have currently most course specific pages translated according to course language preference when the user has not provided any preference, but we need to identify if we have left out any other course specific page and add those to the list of pages which should take the course language setting into consideration.&lt;br /&gt;
&lt;br /&gt;
== Team ==&lt;br /&gt;
&lt;br /&gt;
'''Team Members'''&lt;br /&gt;
&lt;br /&gt;
Reuben M. V. John [[mailto:rmjohn2@ncsu.edu rmjohn2@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Renji Joseph Sabu [[mailto:rsabu@ncsu.edu rsabu@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Ashwin Das [[mailto:adas9@ncsu.edu adas9@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Arnav Julka [[mailto:ajulka@ncsu.edu ajulka@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Mentor'''&lt;br /&gt;
&lt;br /&gt;
Jialin Cui [[mailto:jcui9@ncsu.edu jcui9@ncsu.edu]]&lt;/div&gt;</summary>
		<author><name>Ajulka</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization&amp;diff=142385</id>
		<title>CSC/ECE 517 Fall 2021 - E2159. Expertiza internationalization</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization&amp;diff=142385"/>
		<updated>2021-11-30T06:41:02Z</updated>

		<summary type="html">&lt;p&gt;Ajulka: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Important Links ==&lt;br /&gt;
*Git PR - https://github.com/expertiza/expertiza/pull/2151&lt;br /&gt;
*Git beta branch - https://github.com/arnavjulka/expertiza/tree/beta&lt;br /&gt;
*Overall Video - https://drive.google.com/file/d/1dc9St9J77q-Mb_vRuYBg4vs9Xv0SHm4d/view?usp=sharing&lt;br /&gt;
*Feature Explanation video - &lt;br /&gt;
*Testing Video - https://drive.google.com/file/d/1TOatjhe0wzxTpmWDuC_ryVFmtQ-X7FJq/view?usp=sharing&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Introduction - Purpose &amp;amp; Problem ==&lt;br /&gt;
&lt;br /&gt;
Currently, all Expertiza screens can only be viewed in English. Many Expertiza users are from other countries. This is a problem since this limits the accessibility of Expertiza. An important step in solving this problem is by making Expertiza available in more languages, which is a form of internationalization.&lt;br /&gt;
W3C defines [https://www.w3.org/International/questions/qa-i18n internationalization] as “''the design and development of a product, application or document content that enables easy localization for target audiences that vary in culture, region, or language.''”&lt;br /&gt;
&lt;br /&gt;
[[File:country_pie.png|none|500px|]]&amp;lt;br&amp;gt;&lt;br /&gt;
Survey of home country of Expertiza users for a given course&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Scope:''' The scope of this project is limited however only to static strings. i.e. user-generated content will not be automatically translated to other languages.&lt;br /&gt;
&lt;br /&gt;
'''Breaking down internationalization into 3 sequential subproblems:'''&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Twophase2.jpg|none|700px]]&amp;lt;br&amp;gt;&lt;br /&gt;
'''1. Language selection'''&amp;lt;br&amp;gt;&lt;br /&gt;
Every user has an option to set a language preference in the User Profile Information Edit page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:ProfileEditPage.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
There is also an option where the instructor can choose a default language for a course. &lt;br /&gt;
&lt;br /&gt;
[[File:language2inter.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Thus, the language not only varies from user to user but also across screens for the same user. Thus we need to recompute the language in which the page is to be rendered. If the student has given a language preference, then the choice is given weightage over the course default language chosen by the instructor. &lt;br /&gt;
&lt;br /&gt;
'''2. Rendering the language'''&amp;lt;br&amp;gt;&lt;br /&gt;
'''How do we go about rendering the screen in that language?''' &amp;lt;br&amp;gt;&lt;br /&gt;
In the previous step, we’ve identified the language in which a view is to be rendered. It is important to note that this language may not only differ for a different user, but also for a different page for the same user. The question now becomes, how do we render the screen in this language?&amp;lt;br&amp;gt;&lt;br /&gt;
To tackle this question, we explore 2 fundamental concepts:&amp;lt;br&amp;gt;&lt;br /&gt;
'''2.1 Views are composed of independent language elements'''&amp;lt;br&amp;gt;&lt;br /&gt;
While this is something we typically take for granted, it becomes especially important in the context of translation. That is, a view is not a single contiguous block of text, nor is it an atomic visualization of information (unlike a screenshot), but rather a carefully organized collection of individual elements such as texts, buttons, etc that each contain language that needs to be translated separately. Crucially, this means that we cannot swap out a page in one language in its entirety for a page in another language in its entirety. Instead, each individual element needs to be swapped out individually so as to only impact the language and not the structural composition of the page itself.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''2.2 Views require translation at a large number of call sites'''&amp;lt;br&amp;gt;&lt;br /&gt;
Given that a view is composed of individual elements, this also means that the computation of how to translate such an element such as a button’s text would need to be done separately for each element. This would result in not only a single centralized &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''3. Translation gaps'''&lt;br /&gt;
&lt;br /&gt;
What if the translation for the target language is not available?&lt;br /&gt;
Even translation for a language like Hindi may be available in general, the translation for a given text may not be available Hindi. This may be due to a variety of reasons:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
The specific text may have been accidentally missed out (remember the translation is not being done at runtime through an API, but rather curated by the developer)&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
The given text is non-trivial to translate to the target language&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
Our design would thus need to accommodate this by seamlessly falling back on another language whose translation is available.&lt;br /&gt;
&lt;br /&gt;
== Scope ==&lt;br /&gt;
The scope of this project is limited however only to static strings. I.e. user-generated content will not be automatically translated to other languages.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
'''Proposed Solution''' &amp;lt;br&amp;gt;&lt;br /&gt;
We explore and solve each of the three problems above in isolation:&lt;br /&gt;
&lt;br /&gt;
'''''1. Language selection'''''&amp;lt;br&amp;gt;&lt;br /&gt;
The language in which the page is rendered depends on a set of conditions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;If the user has set a language preference all pages are displayed in that language.&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;If the user has not set a language preference and the user is an instructor, all the pages are displayed in English.&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;If the user has not set a language preference and the user is a student who is on a page that is specific to a course for which the instructor has added a default language, the page is displayed in the course’s default language.&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The below functions are added and called before page rendering to bring in this logic.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  before_action :set_locale&lt;br /&gt;
&lt;br /&gt;
  def set_locale&lt;br /&gt;
    # Checks whether the user is logged in, else the default locale is used&lt;br /&gt;
    if logged_in?&lt;br /&gt;
      # If the current user has set his preferred language, the locale is set according to their preference&lt;br /&gt;
      if @current_user.locale != &amp;quot;no_pref&amp;quot;&lt;br /&gt;
        I18n.locale = @current_user.locale&lt;br /&gt;
        # If the user doesn't have any preference, the locale is taken from the course locale, if the current page is a course specific page or else default locale is used&lt;br /&gt;
      elsif current_user_role? &amp;amp;&amp;amp; current_user_role.student? &amp;amp;&amp;amp; [&amp;quot;student_task&amp;quot;, &amp;quot;sign_up_sheet&amp;quot;, &amp;quot;student_teams&amp;quot;, &amp;quot;student_review&amp;quot;, &amp;quot;grades&amp;quot;, &amp;quot;submitted_content&amp;quot;, &amp;quot;participants&amp;quot;].include?(params[:controller])&lt;br /&gt;
        set_new_locale_for_student&lt;br /&gt;
      else&lt;br /&gt;
        I18n.locale = I18n.default_locale&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      I18n.locale = I18n.default_locale&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def set_new_locale_for_student&lt;br /&gt;
    # Gets participant using student from params&lt;br /&gt;
    if !params[:id].nil? || !params[:student_id].nil?&lt;br /&gt;
      participant_id = params[:id] || params[:student_id]&lt;br /&gt;
      participant = AssignmentParticipant.find_by(id: participant_id)&lt;br /&gt;
      # If id or student_id not correct, revert to locale based on courses.&lt;br /&gt;
      if participant.nil?&lt;br /&gt;
        find_locale_from_courses&lt;br /&gt;
        return&lt;br /&gt;
      end&lt;br /&gt;
      # Find assignment from participant and find locale from the assigment&lt;br /&gt;
      assignment = participant.assignment&lt;br /&gt;
      if !assignment.course.nil?&lt;br /&gt;
        new_locale = assignment.course.locale&lt;br /&gt;
        if !new_locale.nil?&lt;br /&gt;
          I18n.locale = new_locale&lt;br /&gt;
        else&lt;br /&gt;
          I18n.locale = I18n.default_locale&lt;br /&gt;
        end&lt;br /&gt;
      else&lt;br /&gt;
        I18n.locale = I18n.default_locale&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      find_locale_from_courses&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def find_locale_from_courses&lt;br /&gt;
    # If the page is a course or assignment page with no specific student id, every course of that student is checked and if&lt;br /&gt;
    # the language for all these course are same, the page is displayed in that language&lt;br /&gt;
  courseParticipants = CourseParticipant.where(user_id: current_user.id)&lt;br /&gt;
    courseParticipantsLocales = courseParticipants.map { |cp| cp.course.locale }&lt;br /&gt;
    # If no tasks, then possible to have no courses assigned.&lt;br /&gt;
    if courseParticipantsLocales.uniq.length == 1 #&amp;amp;&amp;amp; !@tasks.empty?&lt;br /&gt;
      course = courseParticipants.first.course&lt;br /&gt;
      if course.locale?&lt;br /&gt;
        I18n.locale = course.locale&lt;br /&gt;
      else&lt;br /&gt;
        I18n.locale = I18n.default_locale&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      I18n.locale = I18n.default_locale&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;If the student user has not set a language preference and is not on a course-specific page, then the page is displayed in English.&lt;br /&gt;
If a language preference is obtained by following the above conditions but some keys in the page don't have a translation for the language, the English translation for that key is returned as a fallback.&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''''2. Rendering the language'''''&amp;lt;br&amp;gt;&lt;br /&gt;
Once we have determined the language in which to render the page, we now need to update the rails view code to actually generate the appropriate HTML in the target language. This is the responsibility of the view. However, currently, the actual content of the HTML is hardcoded in (red) English. For example:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;Summary Report for assignment: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;Team: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
As discussed earlier, “Views are composed of independent language elements” and so we cannot simply swap out the entire page content for a separate page in another language (Why? - See “swap out the entire view” in the alternative approaches section):&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;Rapport de synthèse pour l'affectation: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;Équipe: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;Instead, the better approach is to have a single unified view that dynamically changes based on the selected language:&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;&amp;lt;%=language==’en’ ? ‘Summary Report for assignment’ : ‘Rapport de synthèse pour l'affectation’&amp;gt;: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;&amp;lt;%=language==’en’ ? ‘Team’ : ‘Équipe’&amp;gt;: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;However this is clearly infeasible considering the number of call sites where we have to apply this logic. Thus, in order to maximize how concise the call site is, we can pull out this logic into a common helper function:&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;&amp;lt;%=localized(“report_summary.page_header”)&amp;gt;: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;&amp;lt;%=localized(“report_summary.team_label”)&amp;gt;: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;Here the assumption is that the localized(“key”) is aware of the currently selected language and that “report_summary.page_header” is the key for the header which is available in English and Hindi. The helper intelligently selects and returns the right text based on the currently selected language. Through this approach, we are able to render the view in multiple possible languages without any significant increase in the verbosity of the view.&lt;br /&gt;
&lt;br /&gt;
What’s more, is that the above problem is a common problem for user-facing applications and a standard library for doing the above and much more already exists for rails applications called i18n&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''''I18n - Internationalisation, How are we using I18n in Ruby on Rail'''''&amp;lt;br&amp;gt;&lt;br /&gt;
I18n is a ruby library/gem which helps us render the static string on the view dynamically. Dynamicity means that based on a local decision of choosing the current language of the view, the library returns the strings of that particular language at runtime.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
These strings, instead of hardcoding in the view.rb, are provided in external .yml files. Now at the View level, we can pass an id to the 't' function and the I18n library returns the string for that id of the current set language(called as locale). &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:i18n.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
For this purpose, we have to provide .yml files for each language and in those language-specific .yml, we have to provide a map of key-value pairs where the key is the id of the string and value is the string in that particular language. By default the language or locale is set to be English(:en). &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
THE GREATEST BENEFITS of using this library are - &amp;lt;br&amp;gt;&lt;br /&gt;
*The strings aren't hardcoded in the code/build. The strings are being fetched from external files which can be easily modified. For example, if one needs to change the text from 'Please Help' to 'Help', then one just needs to make a change in the .yml file and the change would reflect on the browser. For this change, we didn't need to redeploy the server. We just Decoupled the view when and where from what content is to be shown. &lt;br /&gt;
*Adding more languages is now super easy. Adding support for another language is just one line change in the config and adding a .yml file (having all the key-value pairs for the strings) for the new language. By doing this we can extend the language support as much as we want.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''''3. Translation gaps'''''&lt;br /&gt;
&amp;lt;br&amp;gt;Also, if the language is set to be Hindi or any other language but the key-value pair is not set for that particular string then, automatically the library returns the default which is the English text.&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;config.i18n.fallbacks = [:en]&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Alternate approaches ==&lt;br /&gt;
&lt;br /&gt;
'''1. Why not simply swap out the entire view for another language instead of each text?'''&amp;lt;br&amp;gt;&lt;br /&gt;
A view is an organized collection of multiple separate elements, views often involve dynamic generation and some level of sophistication. If we were to swap out one page in its entirety for another page this would often violate the '''DRY''' principle since we would have to have two separate implementations of the view in each language. Thus in the worst case, you have a complex view that has to be replicated dozens of times in various languages.&lt;br /&gt;
The majority of complexity of the page is not in the content itself but rather the code that executes to generate that content, thus it makes sense to instead maintain a single view and embed the language switching logic at each location where translation needs to occur to avoid replication of everything around it.&lt;br /&gt;
&lt;br /&gt;
'''2. Why did we pick i18n over implementing it ourselves?'''&amp;lt;br&amp;gt;&lt;br /&gt;
Doing it ourselves felt like a great option. But i18n not just selects a language string at runtime for us it does a lot more under the hood which makes our lives easier. For example, it manages locale over the session for us, even if we change the urls and shift tabs and other stuff it manages our locale. &amp;lt;br&amp;gt;&lt;br /&gt;
Also there is a great principle that says - “ If it isn’t broken, Don’t fix it”. The library manages the registering of different language yml files, points to the right right text at runtime, manages session locale and a lot more. So we want to explore this library instead of reimplementing the same thing again.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''3, Why did we store the default language choices in database instead of in session?'''&amp;lt;br&amp;gt;&lt;br /&gt;
We had to decide on whether to keep the student’s language preference in the database or in the session. We have thought about both approaches and below listed are the advantages and disadvantages.&lt;br /&gt;
&lt;br /&gt;
In the work done by the previous team, they added a dropdown in the navbar where a student can choose the preferred language. One of the changes that we did was to move this field to the user profile page. The earlier team used session storage to store the preferred language. This session resets on every logout, but since the preferred language can easily be set from any page this wasn't much of an issue.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Storing user language preference in database.&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	If we are moving the language preference field to the user profile page, it will create some user experience issues if the preference is stored in session. The student will have to visit the user profile page every time they log in. To avoid this scenario, it’s better to keep the language preference in the database, so that the preference stays saved across sessions.&lt;br /&gt;
	The disadvantage of moving the language preference to the database is that it brings forth a schema change and this always requires a very careful going through to ensure that nothing else is affected. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Storing language preference in session storage.&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The main advantage of storing the language preference in session storage is that no schema change is involved. This decreases the chance of other features being affected. The main disadvantage is that the student will have to go to the user profile page every time they log in to set the preference, causing a user experience issue. Keep in mind that we’re moving the field away from the navbar to a user profile page.&lt;br /&gt;
&lt;br /&gt;
After considering these points, we finally decided to go store the user preference in the database itself as the project requires us to add a language preference field in user profile page.&lt;br /&gt;
&lt;br /&gt;
== Use Case Diagram ==&lt;br /&gt;
&amp;lt;li&amp;gt;An instructor can add a default language to any course. English is the default choice.&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;The user has an option to change their preferred language at any time. They have the option to do so in their profile page. &amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;All pages including the course-related and non-course-related pages are displayed in the user preferred language for any user other than student&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Every non-course-related page is displayed in the student’s preferred language. Keys for which a translation is not found are displayed in the default language that is English&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Every course-related page is displayed in the student’s preferred language. If the student doesn’t have a preferred language, the course is displayed in the course’s preferred language. Keys for which a translation is not found are displayed in the default language that is English.&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:usecasediagram.png|2000px|865px]]&lt;br /&gt;
&lt;br /&gt;
== Major design patterns and principles used ==&lt;br /&gt;
&lt;br /&gt;
'''1. DRY: The i18n ‘t’ function'''&amp;lt;br&amp;gt;&lt;br /&gt;
We observe an extreme case of DRY with the t function of i18n.&lt;br /&gt;
For some background, the t function of the library takes in a key representing a text and returns the content referred to by that key in the preferred language of the user. It also performs many other functions such as falling back to a backup language if the translation for the preferred language has not been configured for that specific key. Thus since this logic has to be applied at every element of the view, it would behove us to extract this logic into a reusable function which is what the designers of the i18n library have employed&lt;br /&gt;
&lt;br /&gt;
'''2. Chain of responsibility'''&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Chainofresp.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The I18n library gives us an option to have many fall back options. When the required text for a given language is not found, we then move on to find the text for the next language in the chain and so on until we find it. And in the end we will put english as default language. So if the key value pair for the text is not found in none of the yml files then the text will be fetched from the English language yml file.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''3. Open closed principle &amp;amp; Strategy Pattern'''&amp;lt;br&amp;gt;&lt;br /&gt;
As discussed in the “Language selection&amp;quot; design proposal above, if the user has not selected a preferred language, we do not simply default the view to render in the application language (English). Instead, the project requirements state that for course specific screens such as the assignment view, we would need to render the view in the course’s language.&lt;br /&gt;
While we could implement this code into the application controller that checks the controller being access and accordingly applies overrides on the default language, this violates the open closed principle since we would need to extend this logic any time we introduce a new course specific screen. Instead a better approach is to delegate the decision of selecting the language to the view itself since the view would be most aware of whether the view is course specific or not. We can also preserve the DRYness through mix-ins.&lt;br /&gt;
&lt;br /&gt;
== Database Design ==&lt;br /&gt;
We add the locale field to the users and courses tables which has the default values 0 and 1, which is no preference and en_US respectively.&lt;br /&gt;
&lt;br /&gt;
The migrations will look as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class AddLangLocaleToUsers &amp;lt; ActiveRecord::Migration&lt;br /&gt;
  def change&lt;br /&gt;
    add_column :users, :locale, :integer, default: 0&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class AddLocaleToCourses &amp;lt; ActiveRecord::Migration&lt;br /&gt;
  def change&lt;br /&gt;
    add_column :courses, :locale, :integer, default: 1&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Database Modification ==&lt;br /&gt;
We add a new integer field to the users table to store the user preferred language. The integer will be hashed to the supported languages. The default value in the table will be 0, which will be no_pref.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
enum locale: {&lt;br /&gt;
      no_pref: 0,&lt;br /&gt;
      en_US: 1,&lt;br /&gt;
      hi_IN: 2&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We also add a new integer field to the courses table to store the course preferred language. The integer will be hashed to the supported languages. The default value in the table will be 1, which will be en_US.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
enum locale: {&lt;br /&gt;
      en_US: 1,&lt;br /&gt;
      hi_IN: 2&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Hence the updated courses table will look like following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
create_table &amp;quot;courses&amp;quot;, force: :cascade do |t|&lt;br /&gt;
    t.string   &amp;quot;name&amp;quot;,            limit: 255&lt;br /&gt;
    t.integer  &amp;quot;instructor_id&amp;quot;,   limit: 4&lt;br /&gt;
    t.string   &amp;quot;directory_path&amp;quot;,  limit: 255&lt;br /&gt;
    t.text     &amp;quot;info&amp;quot;,            limit: 65535&lt;br /&gt;
    t.datetime &amp;quot;created_at&amp;quot;&lt;br /&gt;
    t.datetime &amp;quot;updated_at&amp;quot;&lt;br /&gt;
    t.boolean  &amp;quot;private&amp;quot;,                       default: false, null: false&lt;br /&gt;
    t.integer  &amp;quot;institutions_id&amp;quot;, limit: 4&lt;br /&gt;
    t.integer  &amp;quot;locale&amp;quot;,          limit: 4,     default: 1&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
While the updated users table will look like the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
create_table &amp;quot;users&amp;quot;, force: :cascade do |t|&lt;br /&gt;
    t.string  &amp;quot;name&amp;quot;,                      limit: 255,      default: &amp;quot;&amp;quot;,    null: false&lt;br /&gt;
    t.string  &amp;quot;crypted_password&amp;quot;,          limit: 40,       default: &amp;quot;&amp;quot;,    null: false&lt;br /&gt;
    t.integer &amp;quot;role_id&amp;quot;,                   limit: 4,        default: 0,     null: false&lt;br /&gt;
    t.string  &amp;quot;password_salt&amp;quot;,             limit: 255&lt;br /&gt;
    t.string  &amp;quot;fullname&amp;quot;,                  limit: 255&lt;br /&gt;
    t.string  &amp;quot;email&amp;quot;,                     limit: 255&lt;br /&gt;
    t.integer &amp;quot;parent_id&amp;quot;,                 limit: 4&lt;br /&gt;
    t.boolean &amp;quot;private_by_default&amp;quot;,                         default: false&lt;br /&gt;
    t.string  &amp;quot;mru_directory_path&amp;quot;,        limit: 128&lt;br /&gt;
    t.boolean &amp;quot;email_on_review&amp;quot;&lt;br /&gt;
    t.boolean &amp;quot;email_on_submission&amp;quot;&lt;br /&gt;
    t.boolean &amp;quot;email_on_review_of_review&amp;quot;&lt;br /&gt;
    t.boolean &amp;quot;is_new_user&amp;quot;,                                default: true,  null: false&lt;br /&gt;
    t.integer &amp;quot;master_permission_granted&amp;quot;, limit: 1,        default: 0&lt;br /&gt;
    t.string  &amp;quot;handle&amp;quot;,                    limit: 255&lt;br /&gt;
    t.text    &amp;quot;digital_certificate&amp;quot;,       limit: 16777215&lt;br /&gt;
    t.string  &amp;quot;persistence_token&amp;quot;,         limit: 255&lt;br /&gt;
    t.string  &amp;quot;timezonepref&amp;quot;,              limit: 255&lt;br /&gt;
    t.text    &amp;quot;public_key&amp;quot;,                limit: 16777215&lt;br /&gt;
    t.boolean &amp;quot;copy_of_emails&amp;quot;,                             default: false&lt;br /&gt;
    t.integer &amp;quot;institution_id&amp;quot;,            limit: 4&lt;br /&gt;
    t.boolean &amp;quot;preference_home_flag&amp;quot;,                       default: true&lt;br /&gt;
    t.integer &amp;quot;locale&amp;quot;,                    limit: 4,        default: 0&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The locale field is the last column on both tables:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    courses:&amp;gt; t.integer  &amp;quot;locale&amp;quot;,  limit: 4,    default: 1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
      users:&amp;gt; t.integer &amp;quot;locale&amp;quot;,   limit: 4,    default: 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
===Manual Testing===&lt;br /&gt;
&lt;br /&gt;
Through manual testing, we aim to identify if all the features of the application are working as intended when the language conversion occurs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Scenario 1&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Log in to Expertiza as a student.&lt;br /&gt;
&lt;br /&gt;
2. Go to the “User Profile Information” page and change “Preferred Language” to Hindi.&lt;br /&gt;
&lt;br /&gt;
3. Check to see if the English strings on the profile page are translated to Hindi.&lt;br /&gt;
&lt;br /&gt;
4. Check if a page for which Hindi translation keys are added has its English static strings translated to Hindi.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Scenario 2&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Log in to Expertiza as a student.&lt;br /&gt;
&lt;br /&gt;
2. Go to the “User Profile Information” page and change “Preferred Language” to No Preferences.&lt;br /&gt;
&lt;br /&gt;
3.  Check to see if the English strings on the page are unchanged, as the “User Profile Information” translates only if the student has a preference.&lt;br /&gt;
&lt;br /&gt;
4. Go to an assignment page for which Hindi translation keys are added, which is under a course with the default language set to Hindi, and check whether the English strings are translated to Hindi.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Scenario 3&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Log in to Expertiza as a student.&lt;br /&gt;
&lt;br /&gt;
2. Go to the “User Profile Information” page and change “Preferred Language” to Nil.&lt;br /&gt;
&lt;br /&gt;
3.  Check to see if the English strings on the page are unchanged, as the “User Profile Information” translates only if the student has a preference.&lt;br /&gt;
&lt;br /&gt;
4. Go to a non-course-specific page and verify that the page is displayed in English itself, as non of the default languages set for any of the courses should have any role.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Scenario 4&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Log in to Expertiza as a student.&lt;br /&gt;
&lt;br /&gt;
2. Go to the “User Profile Information” page and change “Preferred Language” to Hindi.&lt;br /&gt;
&lt;br /&gt;
3.  Go to a page where translation keys aren’t added completely and make sure that the unspecified keys display strings in English as a fallback.&lt;br /&gt;
&lt;br /&gt;
===Automated Testing===&lt;br /&gt;
Testing Video - https://drive.google.com/file/d/1TOatjhe0wzxTpmWDuC_ryVFmtQ-X7FJq/view?usp=sharing&lt;br /&gt;
&lt;br /&gt;
== Future Scope==&lt;br /&gt;
'''1. Expand to more languages'''&amp;lt;br&amp;gt;&lt;br /&gt;
As part of this project we have targetted Hindi as a second language, however our work makes it easy to extend to other languages as well.&lt;br /&gt;
&lt;br /&gt;
'''2. Identify and implement the course language override on more course specific screens'''&amp;lt;br&amp;gt;&lt;br /&gt;
As part of this project, we have introduced a generic framework by which any view can provide a preferred language in which it should be rendered, this is required by this project for the course language feature set by the instructor.&lt;br /&gt;
We have currently most course specific pages translated according to course language preference when the user has not provided any preference, but we need to identify if we have left out any other course specific page and add those to the list of pages which should take the course language setting into consideration.&lt;br /&gt;
&lt;br /&gt;
== Team ==&lt;br /&gt;
&lt;br /&gt;
'''Team Members'''&lt;br /&gt;
&lt;br /&gt;
Reuben M. V. John [[mailto:rmjohn2@ncsu.edu rmjohn2@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Renji Joseph Sabu [[mailto:rsabu@ncsu.edu rsabu@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Ashwin Das [[mailto:adas9@ncsu.edu adas9@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Arnav Julka [[mailto:ajulka@ncsu.edu ajulka@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Mentor'''&lt;br /&gt;
&lt;br /&gt;
Jialin Cui [[mailto:jcui9@ncsu.edu jcui9@ncsu.edu]]&lt;/div&gt;</summary>
		<author><name>Ajulka</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization&amp;diff=142384</id>
		<title>CSC/ECE 517 Fall 2021 - E2159. Expertiza internationalization</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization&amp;diff=142384"/>
		<updated>2021-11-30T06:39:23Z</updated>

		<summary type="html">&lt;p&gt;Ajulka: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Important Links ==&lt;br /&gt;
*Git PR - https://github.com/expertiza/expertiza/pull/2151&lt;br /&gt;
*Git beta branch - https://github.com/arnavjulka/expertiza/tree/beta&lt;br /&gt;
*Overall Video - https://drive.google.com/file/d/1dc9St9J77q-Mb_vRuYBg4vs9Xv0SHm4d/view?usp=sharing&lt;br /&gt;
*Feature Explanation video - &lt;br /&gt;
*Testing Video - https://drive.google.com/file/d/1TOatjhe0wzxTpmWDuC_ryVFmtQ-X7FJq/view?usp=sharing&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Introduction - Purpose &amp;amp; Problem ==&lt;br /&gt;
&lt;br /&gt;
Currently, all Expertiza screens can only be viewed in English. Many Expertiza users are from other countries. This is a problem since this limits the accessibility of Expertiza. An important step in solving this problem is by making Expertiza available in more languages, which is a form of internationalization.&lt;br /&gt;
W3C defines [https://www.w3.org/International/questions/qa-i18n internationalization] as “''the design and development of a product, application or document content that enables easy localization for target audiences that vary in culture, region, or language.''”&lt;br /&gt;
&lt;br /&gt;
[[File:country_pie.png|none|500px|]]&amp;lt;br&amp;gt;&lt;br /&gt;
Survey of home country of Expertiza users for a given course&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Scope:''' The scope of this project is limited however only to static strings. i.e. user-generated content will not be automatically translated to other languages.&lt;br /&gt;
&lt;br /&gt;
'''Breaking down internationalization into 3 sequential subproblems:'''&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Twophase2.jpg|none|700px]]&amp;lt;br&amp;gt;&lt;br /&gt;
'''1. Language selection'''&amp;lt;br&amp;gt;&lt;br /&gt;
Every user has an option to set a language preference in the User Profile Information Edit page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:ProfileEditPage.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
There is also an option where the instructor can choose a default language for a course. &lt;br /&gt;
&lt;br /&gt;
[[File:language2inter.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Thus, the language not only varies from user to user but also across screens for the same user. Thus we need to recompute the language in which the page is to be rendered. If the student has given a language preference, then the choice is given weightage over the course default language chosen by the instructor. &lt;br /&gt;
&lt;br /&gt;
'''2. Rendering the language'''&amp;lt;br&amp;gt;&lt;br /&gt;
'''How do we go about rendering the screen in that language?''' &amp;lt;br&amp;gt;&lt;br /&gt;
In the previous step, we’ve identified the language in which a view is to be rendered. It is important to note that this language may not only differ for a different user, but also for a different page for the same user. The question now becomes, how do we render the screen in this language?&amp;lt;br&amp;gt;&lt;br /&gt;
To tackle this question, we explore 2 fundamental concepts:&amp;lt;br&amp;gt;&lt;br /&gt;
'''2.1 Views are composed of independent language elements'''&amp;lt;br&amp;gt;&lt;br /&gt;
While this is something we typically take for granted, it becomes especially important in the context of translation. That is, a view is not a single contiguous block of text, nor is it an atomic visualization of information (unlike a screenshot), but rather a carefully organized collection of individual elements such as texts, buttons, etc that each contain language that needs to be translated separately. Crucially, this means that we cannot swap out a page in one language in its entirety for a page in another language in its entirety. Instead, each individual element needs to be swapped out individually so as to only impact the language and not the structural composition of the page itself.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''2.2 Views require translation at a large number of call sites'''&amp;lt;br&amp;gt;&lt;br /&gt;
Given that a view is composed of individual elements, this also means that the computation of how to translate such an element such as a button’s text would need to be done separately for each element. This would result in not only a single centralized &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''3. Translation gaps'''&lt;br /&gt;
&lt;br /&gt;
What if the translation for the target language is not available?&lt;br /&gt;
Even translation for a language like Hindi may be available in general, the translation for a given text may not be available Hindi. This may be due to a variety of reasons:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
The specific text may have been accidentally missed out (remember the translation is not being done at runtime through an API, but rather curated by the developer)&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
The given text is non-trivial to translate to the target language&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
Our design would thus need to accommodate this by seamlessly falling back on another language whose translation is available.&lt;br /&gt;
&lt;br /&gt;
== Scope ==&lt;br /&gt;
The scope of this project is limited however only to static strings. I.e. user-generated content will not be automatically translated to other languages.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
'''Proposed Solution''' &amp;lt;br&amp;gt;&lt;br /&gt;
We explore and solve each of the three problems above in isolation:&lt;br /&gt;
&lt;br /&gt;
'''''1. Language selection'''''&amp;lt;br&amp;gt;&lt;br /&gt;
The language in which the page is rendered depends on a set of conditions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;If the user has set a language preference all pages are displayed in that language.&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;If the user has not set a language preference and the user is an instructor, all the pages are displayed in English.&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;If the user has not set a language preference and the user is a student who is on a page that is specific to a course for which the instructor has added a default language, the page is displayed in the course’s default language.&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The below functions are added and called before page rendering to bring in this logic.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  before_action :set_locale&lt;br /&gt;
&lt;br /&gt;
  def set_locale&lt;br /&gt;
    # Checks whether the user is logged in, else the default locale is used&lt;br /&gt;
    if logged_in?&lt;br /&gt;
      # If the current user has set his preferred language, the locale is set according to their preference&lt;br /&gt;
      if @current_user.locale != &amp;quot;no_pref&amp;quot;&lt;br /&gt;
        I18n.locale = @current_user.locale&lt;br /&gt;
        # If the user doesn't have any preference, the locale is taken from the course locale, if the current page is a course specific page or else default locale is used&lt;br /&gt;
      elsif current_user_role? &amp;amp;&amp;amp; current_user_role.student? &amp;amp;&amp;amp; [&amp;quot;student_task&amp;quot;, &amp;quot;sign_up_sheet&amp;quot;, &amp;quot;student_teams&amp;quot;, &amp;quot;student_review&amp;quot;, &amp;quot;grades&amp;quot;, &amp;quot;submitted_content&amp;quot;, &amp;quot;participants&amp;quot;].include?(params[:controller])&lt;br /&gt;
        set_new_locale_for_student&lt;br /&gt;
      else&lt;br /&gt;
        I18n.locale = I18n.default_locale&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      I18n.locale = I18n.default_locale&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def set_new_locale_for_student&lt;br /&gt;
    # Gets participant using student from params&lt;br /&gt;
    if !params[:id].nil? || !params[:student_id].nil?&lt;br /&gt;
      participant_id = params[:id] || params[:student_id]&lt;br /&gt;
      participant = AssignmentParticipant.find_by(id: participant_id)&lt;br /&gt;
      # If id or student_id not correct, revert to locale based on courses.&lt;br /&gt;
      if participant.nil?&lt;br /&gt;
        find_locale_from_courses&lt;br /&gt;
        return&lt;br /&gt;
      end&lt;br /&gt;
      # Find assignment from participant and find locale from the assigment&lt;br /&gt;
      assignment = participant.assignment&lt;br /&gt;
      if !assignment.course.nil?&lt;br /&gt;
        new_locale = assignment.course.locale&lt;br /&gt;
        if !new_locale.nil?&lt;br /&gt;
          I18n.locale = new_locale&lt;br /&gt;
        else&lt;br /&gt;
          I18n.locale = I18n.default_locale&lt;br /&gt;
        end&lt;br /&gt;
      else&lt;br /&gt;
        I18n.locale = I18n.default_locale&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      find_locale_from_courses&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def find_locale_from_courses&lt;br /&gt;
    # If the page is a course or assignment page with no specific student id, every course of that student is checked and if&lt;br /&gt;
    # the language for all these course are same, the page is displayed in that language&lt;br /&gt;
  courseParticipants = CourseParticipant.where(user_id: current_user.id)&lt;br /&gt;
    courseParticipantsLocales = courseParticipants.map { |cp| cp.course.locale }&lt;br /&gt;
    # If no tasks, then possible to have no courses assigned.&lt;br /&gt;
    if courseParticipantsLocales.uniq.length == 1 #&amp;amp;&amp;amp; !@tasks.empty?&lt;br /&gt;
      course = courseParticipants.first.course&lt;br /&gt;
      if course.locale?&lt;br /&gt;
        I18n.locale = course.locale&lt;br /&gt;
      else&lt;br /&gt;
        I18n.locale = I18n.default_locale&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      I18n.locale = I18n.default_locale&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;If the student user has not set a language preference and is not on a course-specific page, then the page is displayed in English.&lt;br /&gt;
If a language preference is obtained by following the above conditions but some keys in the page don't have a translation for the language, the English translation for that key is returned as a fallback.&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''''2. Rendering the language'''''&amp;lt;br&amp;gt;&lt;br /&gt;
Once we have determined the language in which to render the page, we now need to update the rails view code to actually generate the appropriate HTML in the target language. This is the responsibility of the view. However, currently, the actual content of the HTML is hardcoded in (red) English. For example:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;Summary Report for assignment: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;Team: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
As discussed earlier, “Views are composed of independent language elements” and so we cannot simply swap out the entire page content for a separate page in another language (Why? - See “swap out the entire view” in the alternative approaches section):&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;Rapport de synthèse pour l'affectation: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;Équipe: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;Instead, the better approach is to have a single unified view that dynamically changes based on the selected language:&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;&amp;lt;%=language==’en’ ? ‘Summary Report for assignment’ : ‘Rapport de synthèse pour l'affectation’&amp;gt;: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;&amp;lt;%=language==’en’ ? ‘Team’ : ‘Équipe’&amp;gt;: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;However this is clearly infeasible considering the number of call sites where we have to apply this logic. Thus, in order to maximize how concise the call site is, we can pull out this logic into a common helper function:&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;&amp;lt;%=localized(“report_summary.page_header”)&amp;gt;: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;&amp;lt;%=localized(“report_summary.team_label”)&amp;gt;: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;Here the assumption is that the localized(“key”) is aware of the currently selected language and that “report_summary.page_header” is the key for the header which is available in English and Hindi. The helper intelligently selects and returns the right text based on the currently selected language. Through this approach, we are able to render the view in multiple possible languages without any significant increase in the verbosity of the view.&lt;br /&gt;
&lt;br /&gt;
What’s more, is that the above problem is a common problem for user-facing applications and a standard library for doing the above and much more already exists for rails applications called i18n&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''''I18n - Internationalisation, How are we using I18n in Ruby on Rail'''''&amp;lt;br&amp;gt;&lt;br /&gt;
I18n is a ruby library/gem which helps us render the static string on the view dynamically. Dynamicity means that based on a local decision of choosing the current language of the view, the library returns the strings of that particular language at runtime.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
These strings, instead of hardcoding in the view.rb, are provided in external .yml files. Now at the View level, we can pass an id to the 't' function and the I18n library returns the string for that id of the current set language(called as locale). &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:i18n.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
For this purpose, we have to provide .yml files for each language and in those language-specific .yml, we have to provide a map of key-value pairs where the key is the id of the string and value is the string in that particular language. By default the language or locale is set to be English(:en). &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
THE GREATEST BENEFITS of using this library are - &amp;lt;br&amp;gt;&lt;br /&gt;
*The strings aren't hardcoded in the code/build. The strings are being fetched from external files which can be easily modified. For example, if one needs to change the text from 'Please Help' to 'Help', then one just needs to make a change in the .yml file and the change would reflect on the browser. For this change, we didn't need to redeploy the server. We just Decoupled the view when and where from what content is to be shown. &lt;br /&gt;
*Adding more languages is now super easy. Adding support for another language is just one line change in the config and adding a .yml file (having all the key-value pairs for the strings) for the new language. By doing this we can extend the language support as much as we want.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''''3. Translation gaps'''''&lt;br /&gt;
&amp;lt;br&amp;gt;Also, if the language is set to be Hindi or any other language but the key-value pair is not set for that particular string then, automatically the library returns the default which is the English text.&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;config.i18n.fallbacks = [:en]&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Alternate approaches ==&lt;br /&gt;
&lt;br /&gt;
'''1. Why not simply swap out the entire view for another language instead of each text?'''&amp;lt;br&amp;gt;&lt;br /&gt;
A view is an organized collection of multiple separate elements, views often involve dynamic generation and some level of sophistication. If we were to swap out one page in its entirety for another page this would often violate the '''DRY''' principle since we would have to have two separate implementations of the view in each language. Thus in the worst case, you have a complex view that has to be replicated dozens of times in various languages.&lt;br /&gt;
The majority of complexity of the page is not in the content itself but rather the code that executes to generate that content, thus it makes sense to instead maintain a single view and embed the language switching logic at each location where translation needs to occur to avoid replication of everything around it.&lt;br /&gt;
&lt;br /&gt;
'''2. Why did we pick i18n over implementing it ourselves?'''&amp;lt;br&amp;gt;&lt;br /&gt;
Doing it ourselves felt like a great option. But i18n not just selects a language string at runtime for us it does a lot more under the hood which makes our lives easier. For example, it manages locale over the session for us, even if we change the urls and shift tabs and other stuff it manages our locale. &amp;lt;br&amp;gt;&lt;br /&gt;
Also there is a great principle that says - “ If it isn’t broken, Don’t fix it”. The library manages the registering of different language yml files, points to the right right text at runtime, manages session locale and a lot more. So we want to explore this library instead of reimplementing the same thing again.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''3, Why did we store the default language choices in database instead of in session?'''&amp;lt;br&amp;gt;&lt;br /&gt;
We had to decide on whether to keep the student’s language preference in the database or in the session. We have thought about both approaches and below listed are the advantages and disadvantages.&lt;br /&gt;
&lt;br /&gt;
In the work done by the previous team, they added a dropdown in the navbar where a student can choose the preferred language. One of the changes that we did was to move this field to the user profile page. The earlier team used session storage to store the preferred language. This session resets on every logout, but since the preferred language can easily be set from any page this wasn't much of an issue.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Storing user language preference in database.&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	If we are moving the language preference field to the user profile page, it will create some user experience issues if the preference is stored in session. The student will have to visit the user profile page every time they log in. To avoid this scenario, it’s better to keep the language preference in the database, so that the preference stays saved across sessions.&lt;br /&gt;
	The disadvantage of moving the language preference to the database is that it brings forth a schema change and this always requires a very careful going through to ensure that nothing else is affected. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Storing language preference in session storage.&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The main advantage of storing the language preference in session storage is that no schema change is involved. This decreases the chance of other features being affected. The main disadvantage is that the student will have to go to the user profile page every time they log in to set the preference, causing a user experience issue. Keep in mind that we’re moving the field away from the navbar to a user profile page.&lt;br /&gt;
&lt;br /&gt;
After considering these points, we finally decided to go store the user preference in the database itself as the project requires us to add a language preference field in user profile page.&lt;br /&gt;
&lt;br /&gt;
== Use Case Diagram ==&lt;br /&gt;
&amp;lt;li&amp;gt;An instructor can add a default language to any course. English is the default choice.&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;The user has an option to change their preferred language at any time. They have the option to do so in their profile page. &amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;All pages including the course-related and non-course-related pages are displayed in the user preferred language for any user other than student&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Every non-course-related page is displayed in the student’s preferred language. Keys for which a translation is not found are displayed in the default language that is English&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Every course-related page is displayed in the student’s preferred language. If the student doesn’t have a preferred language, the course is displayed in the course’s preferred language. Keys for which a translation is not found are displayed in the default language that is English.&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:usecasediagram.png|2000px|865px]]&lt;br /&gt;
&lt;br /&gt;
== Major design patterns and principles used ==&lt;br /&gt;
&lt;br /&gt;
'''1. DRY: The i18n ‘t’ function'''&amp;lt;br&amp;gt;&lt;br /&gt;
We observe an extreme case of DRY with the t function of i18n.&lt;br /&gt;
For some background, the t function of the library takes in a key representing a text and returns the content referred to by that key in the preferred language of the user. It also performs many other functions such as falling back to a backup language if the translation for the preferred language has not been configured for that specific key. Thus since this logic has to be applied at every element of the view, it would behove us to extract this logic into a reusable function which is what the designers of the i18n library have employed&lt;br /&gt;
&lt;br /&gt;
'''2. Chain of responsibility'''&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Chainofresp.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The I18n library gives us an option to have many fall back options. When the required text for a given language is not found, we then move on to find the text for the next language in the chain and so on until we find it. And in the end we will put english as default language. So if the key value pair for the text is not found in none of the yml files then the text will be fetched from the English language yml file.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''3. Open closed principle &amp;amp; Strategy Pattern'''&amp;lt;br&amp;gt;&lt;br /&gt;
As discussed in the “Language selection&amp;quot; design proposal above, if the user has not selected a preferred language, we do not simply default the view to render in the application language (English). Instead, the project requirements state that for course specific screens such as the assignment view, we would need to render the view in the course’s language.&lt;br /&gt;
While we could implement this code into the application controller that checks the controller being access and accordingly applies overrides on the default language, this violates the open closed principle since we would need to extend this logic any time we introduce a new course specific screen. Instead a better approach is to delegate the decision of selecting the language to the view itself since the view would be most aware of whether the view is course specific or not. We can also preserve the DRYness through mix-ins.&lt;br /&gt;
&lt;br /&gt;
== Database Design ==&lt;br /&gt;
We add the locale field to the users and courses tables which has the default values 0 and 1, which is no preference and en_US respectively.&lt;br /&gt;
&lt;br /&gt;
The migrations will look as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class AddLangLocaleToUsers &amp;lt; ActiveRecord::Migration&lt;br /&gt;
  def change&lt;br /&gt;
    add_column :users, :locale, :integer, default: 0&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class AddLocaleToCourses &amp;lt; ActiveRecord::Migration&lt;br /&gt;
  def change&lt;br /&gt;
    add_column :courses, :locale, :integer, default: 1&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Database Modification ==&lt;br /&gt;
We add a new integer field to the users table to store the user preferred language. The integer will be hashed to the supported languages. The default value in the table will be 0, which will be no_pref.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
enum locale: {&lt;br /&gt;
      no_pref: 0,&lt;br /&gt;
      en_US: 1,&lt;br /&gt;
      hi_IN: 2&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We also add a new integer field to the courses table to store the course preferred language. The integer will be hashed to the supported languages. The default value in the table will be 1, which will be en_US.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
enum locale: {&lt;br /&gt;
      en_US: 1,&lt;br /&gt;
      hi_IN: 2&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Hence the updated courses table will look like following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
create_table &amp;quot;courses&amp;quot;, force: :cascade do |t|&lt;br /&gt;
    t.string   &amp;quot;name&amp;quot;,            limit: 255&lt;br /&gt;
    t.integer  &amp;quot;instructor_id&amp;quot;,   limit: 4&lt;br /&gt;
    t.string   &amp;quot;directory_path&amp;quot;,  limit: 255&lt;br /&gt;
    t.text     &amp;quot;info&amp;quot;,            limit: 65535&lt;br /&gt;
    t.datetime &amp;quot;created_at&amp;quot;&lt;br /&gt;
    t.datetime &amp;quot;updated_at&amp;quot;&lt;br /&gt;
    t.boolean  &amp;quot;private&amp;quot;,                       default: false, null: false&lt;br /&gt;
    t.integer  &amp;quot;institutions_id&amp;quot;, limit: 4&lt;br /&gt;
    t.integer  &amp;quot;locale&amp;quot;,          limit: 4,     default: 1&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
While the updated users table will look like the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
create_table &amp;quot;users&amp;quot;, force: :cascade do |t|&lt;br /&gt;
    t.string  &amp;quot;name&amp;quot;,                      limit: 255,      default: &amp;quot;&amp;quot;,    null: false&lt;br /&gt;
    t.string  &amp;quot;crypted_password&amp;quot;,          limit: 40,       default: &amp;quot;&amp;quot;,    null: false&lt;br /&gt;
    t.integer &amp;quot;role_id&amp;quot;,                   limit: 4,        default: 0,     null: false&lt;br /&gt;
    t.string  &amp;quot;password_salt&amp;quot;,             limit: 255&lt;br /&gt;
    t.string  &amp;quot;fullname&amp;quot;,                  limit: 255&lt;br /&gt;
    t.string  &amp;quot;email&amp;quot;,                     limit: 255&lt;br /&gt;
    t.integer &amp;quot;parent_id&amp;quot;,                 limit: 4&lt;br /&gt;
    t.boolean &amp;quot;private_by_default&amp;quot;,                         default: false&lt;br /&gt;
    t.string  &amp;quot;mru_directory_path&amp;quot;,        limit: 128&lt;br /&gt;
    t.boolean &amp;quot;email_on_review&amp;quot;&lt;br /&gt;
    t.boolean &amp;quot;email_on_submission&amp;quot;&lt;br /&gt;
    t.boolean &amp;quot;email_on_review_of_review&amp;quot;&lt;br /&gt;
    t.boolean &amp;quot;is_new_user&amp;quot;,                                default: true,  null: false&lt;br /&gt;
    t.integer &amp;quot;master_permission_granted&amp;quot;, limit: 1,        default: 0&lt;br /&gt;
    t.string  &amp;quot;handle&amp;quot;,                    limit: 255&lt;br /&gt;
    t.text    &amp;quot;digital_certificate&amp;quot;,       limit: 16777215&lt;br /&gt;
    t.string  &amp;quot;persistence_token&amp;quot;,         limit: 255&lt;br /&gt;
    t.string  &amp;quot;timezonepref&amp;quot;,              limit: 255&lt;br /&gt;
    t.text    &amp;quot;public_key&amp;quot;,                limit: 16777215&lt;br /&gt;
    t.boolean &amp;quot;copy_of_emails&amp;quot;,                             default: false&lt;br /&gt;
    t.integer &amp;quot;institution_id&amp;quot;,            limit: 4&lt;br /&gt;
    t.boolean &amp;quot;preference_home_flag&amp;quot;,                       default: true&lt;br /&gt;
    t.integer &amp;quot;locale&amp;quot;,                    limit: 4,        default: 0&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The locale field is the last column on both tables:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    courses:&amp;gt; t.integer  &amp;quot;locale&amp;quot;,  limit: 4,    default: 1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
      users:&amp;gt; t.integer &amp;quot;locale&amp;quot;,   limit: 4,    default: 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
===Manual Testing===&lt;br /&gt;
&lt;br /&gt;
Through manual testing, we aim to identify if all the features of the application are working as intended when the language conversion occurs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Scenario 1&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Log in to Expertiza as a student.&lt;br /&gt;
&lt;br /&gt;
2. Go to the “User Profile Information” page and change “Preferred Language” to Hindi.&lt;br /&gt;
&lt;br /&gt;
3. Check to see if the English strings on the profile page are translated to Hindi.&lt;br /&gt;
&lt;br /&gt;
4. Check if a page for which Hindi translation keys are added has its English static strings translated to Hindi.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Scenario 2&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Log in to Expertiza as a student.&lt;br /&gt;
&lt;br /&gt;
2. Go to the “User Profile Information” page and change “Preferred Language” to No Preferences.&lt;br /&gt;
&lt;br /&gt;
3.  Check to see if the English strings on the page are unchanged, as the “User Profile Information” translates only if the student has a preference.&lt;br /&gt;
&lt;br /&gt;
4. Go to an assignment page for which Hindi translation keys are added, which is under a course with the default language set to Hindi, and check whether the English strings are translated to Hindi.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Scenario 3&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Log in to Expertiza as a student.&lt;br /&gt;
&lt;br /&gt;
2. Go to the “User Profile Information” page and change “Preferred Language” to Nil.&lt;br /&gt;
&lt;br /&gt;
3.  Check to see if the English strings on the page are unchanged, as the “User Profile Information” translates only if the student has a preference.&lt;br /&gt;
&lt;br /&gt;
4. Go to a non-course-specific page and verify that the page is displayed in English itself, as non of the default languages set for any of the courses should have any role.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Scenario 4&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Log in to Expertiza as a student.&lt;br /&gt;
&lt;br /&gt;
2. Go to the “User Profile Information” page and change “Preferred Language” to Hindi.&lt;br /&gt;
&lt;br /&gt;
3.  Go to a page where translation keys aren’t added completely and make sure that the unspecified keys display strings in English as a fallback.&lt;br /&gt;
&lt;br /&gt;
== Future Scope==&lt;br /&gt;
'''1. Expand to more languages'''&amp;lt;br&amp;gt;&lt;br /&gt;
As part of this project we have targetted Hindi as a second language, however our work makes it easy to extend to other languages as well.&lt;br /&gt;
&lt;br /&gt;
'''2. Identify and implement the course language override on more course specific screens'''&amp;lt;br&amp;gt;&lt;br /&gt;
As part of this project, we have introduced a generic framework by which any view can provide a preferred language in which it should be rendered, this is required by this project for the course language feature set by the instructor.&lt;br /&gt;
We have currently most course specific pages translated according to course language preference when the user has not provided any preference, but we need to identify if we have left out any other course specific page and add those to the list of pages which should take the course language setting into consideration.&lt;br /&gt;
&lt;br /&gt;
== Team ==&lt;br /&gt;
&lt;br /&gt;
'''Team Members'''&lt;br /&gt;
&lt;br /&gt;
Reuben M. V. John [[mailto:rmjohn2@ncsu.edu rmjohn2@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Renji Joseph Sabu [[mailto:rsabu@ncsu.edu rsabu@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Ashwin Das [[mailto:adas9@ncsu.edu adas9@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Arnav Julka [[mailto:ajulka@ncsu.edu ajulka@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Mentor'''&lt;br /&gt;
&lt;br /&gt;
Jialin Cui [[mailto:jcui9@ncsu.edu jcui9@ncsu.edu]]&lt;/div&gt;</summary>
		<author><name>Ajulka</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization&amp;diff=142383</id>
		<title>CSC/ECE 517 Fall 2021 - E2159. Expertiza internationalization</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization&amp;diff=142383"/>
		<updated>2021-11-30T06:37:24Z</updated>

		<summary type="html">&lt;p&gt;Ajulka: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Important Links ==&lt;br /&gt;
*Git PR - https://github.com/expertiza/expertiza/pull/2151&lt;br /&gt;
*Git beta branch - https://github.com/arnavjulka/expertiza/tree/beta&lt;br /&gt;
*Overall Video - https://drive.google.com/drive/folders/1PGmiJibMtOhjLh6heGUIkq9r0LSDmG6F&lt;br /&gt;
*Feature Explanation video - &lt;br /&gt;
*Testing Video - https://drive.google.com/drive/folders/1PGmiJibMtOhjLh6heGUIkq9r0LSDmG6F&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Introduction - Purpose &amp;amp; Problem ==&lt;br /&gt;
&lt;br /&gt;
Currently, all Expertiza screens can only be viewed in English. Many Expertiza users are from other countries. This is a problem since this limits the accessibility of Expertiza. An important step in solving this problem is by making Expertiza available in more languages, which is a form of internationalization.&lt;br /&gt;
W3C defines [https://www.w3.org/International/questions/qa-i18n internationalization] as “''the design and development of a product, application or document content that enables easy localization for target audiences that vary in culture, region, or language.''”&lt;br /&gt;
&lt;br /&gt;
[[File:country_pie.png|none|500px|]]&amp;lt;br&amp;gt;&lt;br /&gt;
Survey of home country of Expertiza users for a given course&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Scope:''' The scope of this project is limited however only to static strings. i.e. user-generated content will not be automatically translated to other languages.&lt;br /&gt;
&lt;br /&gt;
'''Breaking down internationalization into 3 sequential subproblems:'''&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Twophase2.jpg|none|700px]]&amp;lt;br&amp;gt;&lt;br /&gt;
'''1. Language selection'''&amp;lt;br&amp;gt;&lt;br /&gt;
Every user has an option to set a language preference in the User Profile Information Edit page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:ProfileEditPage.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
There is also an option where the instructor can choose a default language for a course. &lt;br /&gt;
&lt;br /&gt;
[[File:language2inter.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Thus, the language not only varies from user to user but also across screens for the same user. Thus we need to recompute the language in which the page is to be rendered. If the student has given a language preference, then the choice is given weightage over the course default language chosen by the instructor. &lt;br /&gt;
&lt;br /&gt;
'''2. Rendering the language'''&amp;lt;br&amp;gt;&lt;br /&gt;
'''How do we go about rendering the screen in that language?''' &amp;lt;br&amp;gt;&lt;br /&gt;
In the previous step, we’ve identified the language in which a view is to be rendered. It is important to note that this language may not only differ for a different user, but also for a different page for the same user. The question now becomes, how do we render the screen in this language?&amp;lt;br&amp;gt;&lt;br /&gt;
To tackle this question, we explore 2 fundamental concepts:&amp;lt;br&amp;gt;&lt;br /&gt;
'''2.1 Views are composed of independent language elements'''&amp;lt;br&amp;gt;&lt;br /&gt;
While this is something we typically take for granted, it becomes especially important in the context of translation. That is, a view is not a single contiguous block of text, nor is it an atomic visualization of information (unlike a screenshot), but rather a carefully organized collection of individual elements such as texts, buttons, etc that each contain language that needs to be translated separately. Crucially, this means that we cannot swap out a page in one language in its entirety for a page in another language in its entirety. Instead, each individual element needs to be swapped out individually so as to only impact the language and not the structural composition of the page itself.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''2.2 Views require translation at a large number of call sites'''&amp;lt;br&amp;gt;&lt;br /&gt;
Given that a view is composed of individual elements, this also means that the computation of how to translate such an element such as a button’s text would need to be done separately for each element. This would result in not only a single centralized &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''3. Translation gaps'''&lt;br /&gt;
&lt;br /&gt;
What if the translation for the target language is not available?&lt;br /&gt;
Even translation for a language like Hindi may be available in general, the translation for a given text may not be available Hindi. This may be due to a variety of reasons:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
The specific text may have been accidentally missed out (remember the translation is not being done at runtime through an API, but rather curated by the developer)&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
The given text is non-trivial to translate to the target language&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
Our design would thus need to accommodate this by seamlessly falling back on another language whose translation is available.&lt;br /&gt;
&lt;br /&gt;
== Scope ==&lt;br /&gt;
The scope of this project is limited however only to static strings. I.e. user-generated content will not be automatically translated to other languages.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
'''Proposed Solution''' &amp;lt;br&amp;gt;&lt;br /&gt;
We explore and solve each of the three problems above in isolation:&lt;br /&gt;
&lt;br /&gt;
'''''1. Language selection'''''&amp;lt;br&amp;gt;&lt;br /&gt;
The language in which the page is rendered depends on a set of conditions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;If the user has set a language preference all pages are displayed in that language.&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;If the user has not set a language preference and the user is an instructor, all the pages are displayed in English.&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;If the user has not set a language preference and the user is a student who is on a page that is specific to a course for which the instructor has added a default language, the page is displayed in the course’s default language.&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The below functions are added and called before page rendering to bring in this logic.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  before_action :set_locale&lt;br /&gt;
&lt;br /&gt;
  def set_locale&lt;br /&gt;
    # Checks whether the user is logged in, else the default locale is used&lt;br /&gt;
    if logged_in?&lt;br /&gt;
      # If the current user has set his preferred language, the locale is set according to their preference&lt;br /&gt;
      if @current_user.locale != &amp;quot;no_pref&amp;quot;&lt;br /&gt;
        I18n.locale = @current_user.locale&lt;br /&gt;
        # If the user doesn't have any preference, the locale is taken from the course locale, if the current page is a course specific page or else default locale is used&lt;br /&gt;
      elsif current_user_role? &amp;amp;&amp;amp; current_user_role.student? &amp;amp;&amp;amp; [&amp;quot;student_task&amp;quot;, &amp;quot;sign_up_sheet&amp;quot;, &amp;quot;student_teams&amp;quot;, &amp;quot;student_review&amp;quot;, &amp;quot;grades&amp;quot;, &amp;quot;submitted_content&amp;quot;, &amp;quot;participants&amp;quot;].include?(params[:controller])&lt;br /&gt;
        set_new_locale_for_student&lt;br /&gt;
      else&lt;br /&gt;
        I18n.locale = I18n.default_locale&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      I18n.locale = I18n.default_locale&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def set_new_locale_for_student&lt;br /&gt;
    # Gets participant using student from params&lt;br /&gt;
    if !params[:id].nil? || !params[:student_id].nil?&lt;br /&gt;
      participant_id = params[:id] || params[:student_id]&lt;br /&gt;
      participant = AssignmentParticipant.find_by(id: participant_id)&lt;br /&gt;
      # If id or student_id not correct, revert to locale based on courses.&lt;br /&gt;
      if participant.nil?&lt;br /&gt;
        find_locale_from_courses&lt;br /&gt;
        return&lt;br /&gt;
      end&lt;br /&gt;
      # Find assignment from participant and find locale from the assigment&lt;br /&gt;
      assignment = participant.assignment&lt;br /&gt;
      if !assignment.course.nil?&lt;br /&gt;
        new_locale = assignment.course.locale&lt;br /&gt;
        if !new_locale.nil?&lt;br /&gt;
          I18n.locale = new_locale&lt;br /&gt;
        else&lt;br /&gt;
          I18n.locale = I18n.default_locale&lt;br /&gt;
        end&lt;br /&gt;
      else&lt;br /&gt;
        I18n.locale = I18n.default_locale&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      find_locale_from_courses&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def find_locale_from_courses&lt;br /&gt;
    # If the page is a course or assignment page with no specific student id, every course of that student is checked and if&lt;br /&gt;
    # the language for all these course are same, the page is displayed in that language&lt;br /&gt;
  courseParticipants = CourseParticipant.where(user_id: current_user.id)&lt;br /&gt;
    courseParticipantsLocales = courseParticipants.map { |cp| cp.course.locale }&lt;br /&gt;
    # If no tasks, then possible to have no courses assigned.&lt;br /&gt;
    if courseParticipantsLocales.uniq.length == 1 #&amp;amp;&amp;amp; !@tasks.empty?&lt;br /&gt;
      course = courseParticipants.first.course&lt;br /&gt;
      if course.locale?&lt;br /&gt;
        I18n.locale = course.locale&lt;br /&gt;
      else&lt;br /&gt;
        I18n.locale = I18n.default_locale&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      I18n.locale = I18n.default_locale&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;If the student user has not set a language preference and is not on a course-specific page, then the page is displayed in English.&lt;br /&gt;
If a language preference is obtained by following the above conditions but some keys in the page don't have a translation for the language, the English translation for that key is returned as a fallback.&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''''2. Rendering the language'''''&amp;lt;br&amp;gt;&lt;br /&gt;
Once we have determined the language in which to render the page, we now need to update the rails view code to actually generate the appropriate HTML in the target language. This is the responsibility of the view. However, currently, the actual content of the HTML is hardcoded in (red) English. For example:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;Summary Report for assignment: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;Team: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
As discussed earlier, “Views are composed of independent language elements” and so we cannot simply swap out the entire page content for a separate page in another language (Why? - See “swap out the entire view” in the alternative approaches section):&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;Rapport de synthèse pour l'affectation: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;Équipe: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;Instead, the better approach is to have a single unified view that dynamically changes based on the selected language:&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;&amp;lt;%=language==’en’ ? ‘Summary Report for assignment’ : ‘Rapport de synthèse pour l'affectation’&amp;gt;: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;&amp;lt;%=language==’en’ ? ‘Team’ : ‘Équipe’&amp;gt;: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;However this is clearly infeasible considering the number of call sites where we have to apply this logic. Thus, in order to maximize how concise the call site is, we can pull out this logic into a common helper function:&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;&amp;lt;%=localized(“report_summary.page_header”)&amp;gt;: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;&amp;lt;%=localized(“report_summary.team_label”)&amp;gt;: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;Here the assumption is that the localized(“key”) is aware of the currently selected language and that “report_summary.page_header” is the key for the header which is available in English and Hindi. The helper intelligently selects and returns the right text based on the currently selected language. Through this approach, we are able to render the view in multiple possible languages without any significant increase in the verbosity of the view.&lt;br /&gt;
&lt;br /&gt;
What’s more, is that the above problem is a common problem for user-facing applications and a standard library for doing the above and much more already exists for rails applications called i18n&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''''I18n - Internationalisation, How are we using I18n in Ruby on Rail'''''&amp;lt;br&amp;gt;&lt;br /&gt;
I18n is a ruby library/gem which helps us render the static string on the view dynamically. Dynamicity means that based on a local decision of choosing the current language of the view, the library returns the strings of that particular language at runtime.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
These strings, instead of hardcoding in the view.rb, are provided in external .yml files. Now at the View level, we can pass an id to the 't' function and the I18n library returns the string for that id of the current set language(called as locale). &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:i18n.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
For this purpose, we have to provide .yml files for each language and in those language-specific .yml, we have to provide a map of key-value pairs where the key is the id of the string and value is the string in that particular language. By default the language or locale is set to be English(:en). &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
THE GREATEST BENEFITS of using this library are - &amp;lt;br&amp;gt;&lt;br /&gt;
*The strings aren't hardcoded in the code/build. The strings are being fetched from external files which can be easily modified. For example, if one needs to change the text from 'Please Help' to 'Help', then one just needs to make a change in the .yml file and the change would reflect on the browser. For this change, we didn't need to redeploy the server. We just Decoupled the view when and where from what content is to be shown. &lt;br /&gt;
*Adding more languages is now super easy. Adding support for another language is just one line change in the config and adding a .yml file (having all the key-value pairs for the strings) for the new language. By doing this we can extend the language support as much as we want.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''''3. Translation gaps'''''&lt;br /&gt;
&amp;lt;br&amp;gt;Also, if the language is set to be Hindi or any other language but the key-value pair is not set for that particular string then, automatically the library returns the default which is the English text.&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;config.i18n.fallbacks = [:en]&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Alternate approaches ==&lt;br /&gt;
&lt;br /&gt;
'''1. Why not simply swap out the entire view for another language instead of each text?'''&amp;lt;br&amp;gt;&lt;br /&gt;
A view is an organized collection of multiple separate elements, views often involve dynamic generation and some level of sophistication. If we were to swap out one page in its entirety for another page this would often violate the '''DRY''' principle since we would have to have two separate implementations of the view in each language. Thus in the worst case, you have a complex view that has to be replicated dozens of times in various languages.&lt;br /&gt;
The majority of complexity of the page is not in the content itself but rather the code that executes to generate that content, thus it makes sense to instead maintain a single view and embed the language switching logic at each location where translation needs to occur to avoid replication of everything around it.&lt;br /&gt;
&lt;br /&gt;
'''2. Why did we pick i18n over implementing it ourselves?'''&amp;lt;br&amp;gt;&lt;br /&gt;
Doing it ourselves felt like a great option. But i18n not just selects a language string at runtime for us it does a lot more under the hood which makes our lives easier. For example, it manages locale over the session for us, even if we change the urls and shift tabs and other stuff it manages our locale. &amp;lt;br&amp;gt;&lt;br /&gt;
Also there is a great principle that says - “ If it isn’t broken, Don’t fix it”. The library manages the registering of different language yml files, points to the right right text at runtime, manages session locale and a lot more. So we want to explore this library instead of reimplementing the same thing again.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''3, Why did we store the default language choices in database instead of in session?'''&amp;lt;br&amp;gt;&lt;br /&gt;
We had to decide on whether to keep the student’s language preference in the database or in the session. We have thought about both approaches and below listed are the advantages and disadvantages.&lt;br /&gt;
&lt;br /&gt;
In the work done by the previous team, they added a dropdown in the navbar where a student can choose the preferred language. One of the changes that we did was to move this field to the user profile page. The earlier team used session storage to store the preferred language. This session resets on every logout, but since the preferred language can easily be set from any page this wasn't much of an issue.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Storing user language preference in database.&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	If we are moving the language preference field to the user profile page, it will create some user experience issues if the preference is stored in session. The student will have to visit the user profile page every time they log in. To avoid this scenario, it’s better to keep the language preference in the database, so that the preference stays saved across sessions.&lt;br /&gt;
	The disadvantage of moving the language preference to the database is that it brings forth a schema change and this always requires a very careful going through to ensure that nothing else is affected. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Storing language preference in session storage.&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The main advantage of storing the language preference in session storage is that no schema change is involved. This decreases the chance of other features being affected. The main disadvantage is that the student will have to go to the user profile page every time they log in to set the preference, causing a user experience issue. Keep in mind that we’re moving the field away from the navbar to a user profile page.&lt;br /&gt;
&lt;br /&gt;
After considering these points, we finally decided to go store the user preference in the database itself as the project requires us to add a language preference field in user profile page.&lt;br /&gt;
&lt;br /&gt;
== Use Case Diagram ==&lt;br /&gt;
&amp;lt;li&amp;gt;An instructor can add a default language to any course. English is the default choice.&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;The user has an option to change their preferred language at any time. They have the option to do so in their profile page. &amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;All pages including the course-related and non-course-related pages are displayed in the user preferred language for any user other than student&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Every non-course-related page is displayed in the student’s preferred language. Keys for which a translation is not found are displayed in the default language that is English&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Every course-related page is displayed in the student’s preferred language. If the student doesn’t have a preferred language, the course is displayed in the course’s preferred language. Keys for which a translation is not found are displayed in the default language that is English.&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:usecasediagram.png|2000px|865px]]&lt;br /&gt;
&lt;br /&gt;
== Major design patterns and principles used ==&lt;br /&gt;
&lt;br /&gt;
'''1. DRY: The i18n ‘t’ function'''&amp;lt;br&amp;gt;&lt;br /&gt;
We observe an extreme case of DRY with the t function of i18n.&lt;br /&gt;
For some background, the t function of the library takes in a key representing a text and returns the content referred to by that key in the preferred language of the user. It also performs many other functions such as falling back to a backup language if the translation for the preferred language has not been configured for that specific key. Thus since this logic has to be applied at every element of the view, it would behove us to extract this logic into a reusable function which is what the designers of the i18n library have employed&lt;br /&gt;
&lt;br /&gt;
'''2. Chain of responsibility'''&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Chainofresp.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The I18n library gives us an option to have many fall back options. When the required text for a given language is not found, we then move on to find the text for the next language in the chain and so on until we find it. And in the end we will put english as default language. So if the key value pair for the text is not found in none of the yml files then the text will be fetched from the English language yml file.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''3. Open closed principle &amp;amp; Strategy Pattern'''&amp;lt;br&amp;gt;&lt;br /&gt;
As discussed in the “Language selection&amp;quot; design proposal above, if the user has not selected a preferred language, we do not simply default the view to render in the application language (English). Instead, the project requirements state that for course specific screens such as the assignment view, we would need to render the view in the course’s language.&lt;br /&gt;
While we could implement this code into the application controller that checks the controller being access and accordingly applies overrides on the default language, this violates the open closed principle since we would need to extend this logic any time we introduce a new course specific screen. Instead a better approach is to delegate the decision of selecting the language to the view itself since the view would be most aware of whether the view is course specific or not. We can also preserve the DRYness through mix-ins.&lt;br /&gt;
&lt;br /&gt;
== Database Design ==&lt;br /&gt;
We add the locale field to the users and courses tables which has the default values 0 and 1, which is no preference and en_US respectively.&lt;br /&gt;
&lt;br /&gt;
The migrations will look as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class AddLangLocaleToUsers &amp;lt; ActiveRecord::Migration&lt;br /&gt;
  def change&lt;br /&gt;
    add_column :users, :locale, :integer, default: 0&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class AddLocaleToCourses &amp;lt; ActiveRecord::Migration&lt;br /&gt;
  def change&lt;br /&gt;
    add_column :courses, :locale, :integer, default: 1&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Database Modification ==&lt;br /&gt;
We add a new integer field to the users table to store the user preferred language. The integer will be hashed to the supported languages. The default value in the table will be 0, which will be no_pref.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
enum locale: {&lt;br /&gt;
      no_pref: 0,&lt;br /&gt;
      en_US: 1,&lt;br /&gt;
      hi_IN: 2&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We also add a new integer field to the courses table to store the course preferred language. The integer will be hashed to the supported languages. The default value in the table will be 1, which will be en_US.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
enum locale: {&lt;br /&gt;
      en_US: 1,&lt;br /&gt;
      hi_IN: 2&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Hence the updated courses table will look like following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
create_table &amp;quot;courses&amp;quot;, force: :cascade do |t|&lt;br /&gt;
    t.string   &amp;quot;name&amp;quot;,            limit: 255&lt;br /&gt;
    t.integer  &amp;quot;instructor_id&amp;quot;,   limit: 4&lt;br /&gt;
    t.string   &amp;quot;directory_path&amp;quot;,  limit: 255&lt;br /&gt;
    t.text     &amp;quot;info&amp;quot;,            limit: 65535&lt;br /&gt;
    t.datetime &amp;quot;created_at&amp;quot;&lt;br /&gt;
    t.datetime &amp;quot;updated_at&amp;quot;&lt;br /&gt;
    t.boolean  &amp;quot;private&amp;quot;,                       default: false, null: false&lt;br /&gt;
    t.integer  &amp;quot;institutions_id&amp;quot;, limit: 4&lt;br /&gt;
    t.integer  &amp;quot;locale&amp;quot;,          limit: 4,     default: 1&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
While the updated users table will look like the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
create_table &amp;quot;users&amp;quot;, force: :cascade do |t|&lt;br /&gt;
    t.string  &amp;quot;name&amp;quot;,                      limit: 255,      default: &amp;quot;&amp;quot;,    null: false&lt;br /&gt;
    t.string  &amp;quot;crypted_password&amp;quot;,          limit: 40,       default: &amp;quot;&amp;quot;,    null: false&lt;br /&gt;
    t.integer &amp;quot;role_id&amp;quot;,                   limit: 4,        default: 0,     null: false&lt;br /&gt;
    t.string  &amp;quot;password_salt&amp;quot;,             limit: 255&lt;br /&gt;
    t.string  &amp;quot;fullname&amp;quot;,                  limit: 255&lt;br /&gt;
    t.string  &amp;quot;email&amp;quot;,                     limit: 255&lt;br /&gt;
    t.integer &amp;quot;parent_id&amp;quot;,                 limit: 4&lt;br /&gt;
    t.boolean &amp;quot;private_by_default&amp;quot;,                         default: false&lt;br /&gt;
    t.string  &amp;quot;mru_directory_path&amp;quot;,        limit: 128&lt;br /&gt;
    t.boolean &amp;quot;email_on_review&amp;quot;&lt;br /&gt;
    t.boolean &amp;quot;email_on_submission&amp;quot;&lt;br /&gt;
    t.boolean &amp;quot;email_on_review_of_review&amp;quot;&lt;br /&gt;
    t.boolean &amp;quot;is_new_user&amp;quot;,                                default: true,  null: false&lt;br /&gt;
    t.integer &amp;quot;master_permission_granted&amp;quot;, limit: 1,        default: 0&lt;br /&gt;
    t.string  &amp;quot;handle&amp;quot;,                    limit: 255&lt;br /&gt;
    t.text    &amp;quot;digital_certificate&amp;quot;,       limit: 16777215&lt;br /&gt;
    t.string  &amp;quot;persistence_token&amp;quot;,         limit: 255&lt;br /&gt;
    t.string  &amp;quot;timezonepref&amp;quot;,              limit: 255&lt;br /&gt;
    t.text    &amp;quot;public_key&amp;quot;,                limit: 16777215&lt;br /&gt;
    t.boolean &amp;quot;copy_of_emails&amp;quot;,                             default: false&lt;br /&gt;
    t.integer &amp;quot;institution_id&amp;quot;,            limit: 4&lt;br /&gt;
    t.boolean &amp;quot;preference_home_flag&amp;quot;,                       default: true&lt;br /&gt;
    t.integer &amp;quot;locale&amp;quot;,                    limit: 4,        default: 0&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The locale field is the last column on both tables:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    courses:&amp;gt; t.integer  &amp;quot;locale&amp;quot;,  limit: 4,    default: 1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
      users:&amp;gt; t.integer &amp;quot;locale&amp;quot;,   limit: 4,    default: 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
===Manual Testing===&lt;br /&gt;
&lt;br /&gt;
Through manual testing, we aim to identify if all the features of the application are working as intended when the language conversion occurs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Scenario 1&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Log in to Expertiza as a student.&lt;br /&gt;
&lt;br /&gt;
2. Go to the “User Profile Information” page and change “Preferred Language” to Hindi.&lt;br /&gt;
&lt;br /&gt;
3. Check to see if the English strings on the profile page are translated to Hindi.&lt;br /&gt;
&lt;br /&gt;
4. Check if a page for which Hindi translation keys are added has its English static strings translated to Hindi.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Scenario 2&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Log in to Expertiza as a student.&lt;br /&gt;
&lt;br /&gt;
2. Go to the “User Profile Information” page and change “Preferred Language” to No Preferences.&lt;br /&gt;
&lt;br /&gt;
3.  Check to see if the English strings on the page are unchanged, as the “User Profile Information” translates only if the student has a preference.&lt;br /&gt;
&lt;br /&gt;
4. Go to an assignment page for which Hindi translation keys are added, which is under a course with the default language set to Hindi, and check whether the English strings are translated to Hindi.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Scenario 3&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Log in to Expertiza as a student.&lt;br /&gt;
&lt;br /&gt;
2. Go to the “User Profile Information” page and change “Preferred Language” to Nil.&lt;br /&gt;
&lt;br /&gt;
3.  Check to see if the English strings on the page are unchanged, as the “User Profile Information” translates only if the student has a preference.&lt;br /&gt;
&lt;br /&gt;
4. Go to a non-course-specific page and verify that the page is displayed in English itself, as non of the default languages set for any of the courses should have any role.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Scenario 4&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Log in to Expertiza as a student.&lt;br /&gt;
&lt;br /&gt;
2. Go to the “User Profile Information” page and change “Preferred Language” to Hindi.&lt;br /&gt;
&lt;br /&gt;
3.  Go to a page where translation keys aren’t added completely and make sure that the unspecified keys display strings in English as a fallback.&lt;br /&gt;
&lt;br /&gt;
== Future Scope==&lt;br /&gt;
'''1. Expand to more languages'''&amp;lt;br&amp;gt;&lt;br /&gt;
As part of this project we have targetted Hindi as a second language, however our work makes it easy to extend to other languages as well.&lt;br /&gt;
&lt;br /&gt;
'''2. Identify and implement the course language override on more course specific screens'''&amp;lt;br&amp;gt;&lt;br /&gt;
As part of this project, we have introduced a generic framework by which any view can provide a preferred language in which it should be rendered, this is required by this project for the course language feature set by the instructor.&lt;br /&gt;
We have currently most course specific pages translated according to course language preference when the user has not provided any preference, but we need to identify if we have left out any other course specific page and add those to the list of pages which should take the course language setting into consideration.&lt;br /&gt;
&lt;br /&gt;
== Team ==&lt;br /&gt;
&lt;br /&gt;
'''Team Members'''&lt;br /&gt;
&lt;br /&gt;
Reuben M. V. John [[mailto:rmjohn2@ncsu.edu rmjohn2@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Renji Joseph Sabu [[mailto:rsabu@ncsu.edu rsabu@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Ashwin Das [[mailto:adas9@ncsu.edu adas9@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Arnav Julka [[mailto:ajulka@ncsu.edu ajulka@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Mentor'''&lt;br /&gt;
&lt;br /&gt;
Jialin Cui [[mailto:jcui9@ncsu.edu jcui9@ncsu.edu]]&lt;/div&gt;</summary>
		<author><name>Ajulka</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization&amp;diff=142382</id>
		<title>CSC/ECE 517 Fall 2021 - E2159. Expertiza internationalization</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization&amp;diff=142382"/>
		<updated>2021-11-30T06:36:04Z</updated>

		<summary type="html">&lt;p&gt;Ajulka: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Important Links ==&lt;br /&gt;
*Git PR - https://github.com/expertiza/expertiza/pull/2151&lt;br /&gt;
*Git beta branch - https://github.com/arnavjulka/expertiza/tree/beta&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Introduction - Purpose &amp;amp; Problem ==&lt;br /&gt;
&lt;br /&gt;
Currently, all Expertiza screens can only be viewed in English. Many Expertiza users are from other countries. This is a problem since this limits the accessibility of Expertiza. An important step in solving this problem is by making Expertiza available in more languages, which is a form of internationalization.&lt;br /&gt;
W3C defines [https://www.w3.org/International/questions/qa-i18n internationalization] as “''the design and development of a product, application or document content that enables easy localization for target audiences that vary in culture, region, or language.''”&lt;br /&gt;
&lt;br /&gt;
[[File:country_pie.png|none|500px|]]&amp;lt;br&amp;gt;&lt;br /&gt;
Survey of home country of Expertiza users for a given course&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Scope:''' The scope of this project is limited however only to static strings. i.e. user-generated content will not be automatically translated to other languages.&lt;br /&gt;
&lt;br /&gt;
'''Breaking down internationalization into 3 sequential subproblems:'''&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Twophase2.jpg|none|700px]]&amp;lt;br&amp;gt;&lt;br /&gt;
'''1. Language selection'''&amp;lt;br&amp;gt;&lt;br /&gt;
Every user has an option to set a language preference in the User Profile Information Edit page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:ProfileEditPage.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
There is also an option where the instructor can choose a default language for a course. &lt;br /&gt;
&lt;br /&gt;
[[File:language2inter.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Thus, the language not only varies from user to user but also across screens for the same user. Thus we need to recompute the language in which the page is to be rendered. If the student has given a language preference, then the choice is given weightage over the course default language chosen by the instructor. &lt;br /&gt;
&lt;br /&gt;
'''2. Rendering the language'''&amp;lt;br&amp;gt;&lt;br /&gt;
'''How do we go about rendering the screen in that language?''' &amp;lt;br&amp;gt;&lt;br /&gt;
In the previous step, we’ve identified the language in which a view is to be rendered. It is important to note that this language may not only differ for a different user, but also for a different page for the same user. The question now becomes, how do we render the screen in this language?&amp;lt;br&amp;gt;&lt;br /&gt;
To tackle this question, we explore 2 fundamental concepts:&amp;lt;br&amp;gt;&lt;br /&gt;
'''2.1 Views are composed of independent language elements'''&amp;lt;br&amp;gt;&lt;br /&gt;
While this is something we typically take for granted, it becomes especially important in the context of translation. That is, a view is not a single contiguous block of text, nor is it an atomic visualization of information (unlike a screenshot), but rather a carefully organized collection of individual elements such as texts, buttons, etc that each contain language that needs to be translated separately. Crucially, this means that we cannot swap out a page in one language in its entirety for a page in another language in its entirety. Instead, each individual element needs to be swapped out individually so as to only impact the language and not the structural composition of the page itself.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''2.2 Views require translation at a large number of call sites'''&amp;lt;br&amp;gt;&lt;br /&gt;
Given that a view is composed of individual elements, this also means that the computation of how to translate such an element such as a button’s text would need to be done separately for each element. This would result in not only a single centralized &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''3. Translation gaps'''&lt;br /&gt;
&lt;br /&gt;
What if the translation for the target language is not available?&lt;br /&gt;
Even translation for a language like Hindi may be available in general, the translation for a given text may not be available Hindi. This may be due to a variety of reasons:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
The specific text may have been accidentally missed out (remember the translation is not being done at runtime through an API, but rather curated by the developer)&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
The given text is non-trivial to translate to the target language&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
Our design would thus need to accommodate this by seamlessly falling back on another language whose translation is available.&lt;br /&gt;
&lt;br /&gt;
== Scope ==&lt;br /&gt;
The scope of this project is limited however only to static strings. I.e. user-generated content will not be automatically translated to other languages.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
'''Proposed Solution''' &amp;lt;br&amp;gt;&lt;br /&gt;
We explore and solve each of the three problems above in isolation:&lt;br /&gt;
&lt;br /&gt;
'''''1. Language selection'''''&amp;lt;br&amp;gt;&lt;br /&gt;
The language in which the page is rendered depends on a set of conditions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;If the user has set a language preference all pages are displayed in that language.&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;If the user has not set a language preference and the user is an instructor, all the pages are displayed in English.&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;If the user has not set a language preference and the user is a student who is on a page that is specific to a course for which the instructor has added a default language, the page is displayed in the course’s default language.&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The below functions are added and called before page rendering to bring in this logic.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  before_action :set_locale&lt;br /&gt;
&lt;br /&gt;
  def set_locale&lt;br /&gt;
    # Checks whether the user is logged in, else the default locale is used&lt;br /&gt;
    if logged_in?&lt;br /&gt;
      # If the current user has set his preferred language, the locale is set according to their preference&lt;br /&gt;
      if @current_user.locale != &amp;quot;no_pref&amp;quot;&lt;br /&gt;
        I18n.locale = @current_user.locale&lt;br /&gt;
        # If the user doesn't have any preference, the locale is taken from the course locale, if the current page is a course specific page or else default locale is used&lt;br /&gt;
      elsif current_user_role? &amp;amp;&amp;amp; current_user_role.student? &amp;amp;&amp;amp; [&amp;quot;student_task&amp;quot;, &amp;quot;sign_up_sheet&amp;quot;, &amp;quot;student_teams&amp;quot;, &amp;quot;student_review&amp;quot;, &amp;quot;grades&amp;quot;, &amp;quot;submitted_content&amp;quot;, &amp;quot;participants&amp;quot;].include?(params[:controller])&lt;br /&gt;
        set_new_locale_for_student&lt;br /&gt;
      else&lt;br /&gt;
        I18n.locale = I18n.default_locale&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      I18n.locale = I18n.default_locale&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def set_new_locale_for_student&lt;br /&gt;
    # Gets participant using student from params&lt;br /&gt;
    if !params[:id].nil? || !params[:student_id].nil?&lt;br /&gt;
      participant_id = params[:id] || params[:student_id]&lt;br /&gt;
      participant = AssignmentParticipant.find_by(id: participant_id)&lt;br /&gt;
      # If id or student_id not correct, revert to locale based on courses.&lt;br /&gt;
      if participant.nil?&lt;br /&gt;
        find_locale_from_courses&lt;br /&gt;
        return&lt;br /&gt;
      end&lt;br /&gt;
      # Find assignment from participant and find locale from the assigment&lt;br /&gt;
      assignment = participant.assignment&lt;br /&gt;
      if !assignment.course.nil?&lt;br /&gt;
        new_locale = assignment.course.locale&lt;br /&gt;
        if !new_locale.nil?&lt;br /&gt;
          I18n.locale = new_locale&lt;br /&gt;
        else&lt;br /&gt;
          I18n.locale = I18n.default_locale&lt;br /&gt;
        end&lt;br /&gt;
      else&lt;br /&gt;
        I18n.locale = I18n.default_locale&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      find_locale_from_courses&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def find_locale_from_courses&lt;br /&gt;
    # If the page is a course or assignment page with no specific student id, every course of that student is checked and if&lt;br /&gt;
    # the language for all these course are same, the page is displayed in that language&lt;br /&gt;
  courseParticipants = CourseParticipant.where(user_id: current_user.id)&lt;br /&gt;
    courseParticipantsLocales = courseParticipants.map { |cp| cp.course.locale }&lt;br /&gt;
    # If no tasks, then possible to have no courses assigned.&lt;br /&gt;
    if courseParticipantsLocales.uniq.length == 1 #&amp;amp;&amp;amp; !@tasks.empty?&lt;br /&gt;
      course = courseParticipants.first.course&lt;br /&gt;
      if course.locale?&lt;br /&gt;
        I18n.locale = course.locale&lt;br /&gt;
      else&lt;br /&gt;
        I18n.locale = I18n.default_locale&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      I18n.locale = I18n.default_locale&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;If the student user has not set a language preference and is not on a course-specific page, then the page is displayed in English.&lt;br /&gt;
If a language preference is obtained by following the above conditions but some keys in the page don't have a translation for the language, the English translation for that key is returned as a fallback.&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''''2. Rendering the language'''''&amp;lt;br&amp;gt;&lt;br /&gt;
Once we have determined the language in which to render the page, we now need to update the rails view code to actually generate the appropriate HTML in the target language. This is the responsibility of the view. However, currently, the actual content of the HTML is hardcoded in (red) English. For example:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;Summary Report for assignment: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;Team: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
As discussed earlier, “Views are composed of independent language elements” and so we cannot simply swap out the entire page content for a separate page in another language (Why? - See “swap out the entire view” in the alternative approaches section):&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;Rapport de synthèse pour l'affectation: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;Équipe: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;Instead, the better approach is to have a single unified view that dynamically changes based on the selected language:&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;&amp;lt;%=language==’en’ ? ‘Summary Report for assignment’ : ‘Rapport de synthèse pour l'affectation’&amp;gt;: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;&amp;lt;%=language==’en’ ? ‘Team’ : ‘Équipe’&amp;gt;: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;However this is clearly infeasible considering the number of call sites where we have to apply this logic. Thus, in order to maximize how concise the call site is, we can pull out this logic into a common helper function:&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;&amp;lt;%=localized(“report_summary.page_header”)&amp;gt;: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;&amp;lt;%=localized(“report_summary.team_label”)&amp;gt;: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;Here the assumption is that the localized(“key”) is aware of the currently selected language and that “report_summary.page_header” is the key for the header which is available in English and Hindi. The helper intelligently selects and returns the right text based on the currently selected language. Through this approach, we are able to render the view in multiple possible languages without any significant increase in the verbosity of the view.&lt;br /&gt;
&lt;br /&gt;
What’s more, is that the above problem is a common problem for user-facing applications and a standard library for doing the above and much more already exists for rails applications called i18n&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''''I18n - Internationalisation, How are we using I18n in Ruby on Rail'''''&amp;lt;br&amp;gt;&lt;br /&gt;
I18n is a ruby library/gem which helps us render the static string on the view dynamically. Dynamicity means that based on a local decision of choosing the current language of the view, the library returns the strings of that particular language at runtime.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
These strings, instead of hardcoding in the view.rb, are provided in external .yml files. Now at the View level, we can pass an id to the 't' function and the I18n library returns the string for that id of the current set language(called as locale). &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:i18n.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
For this purpose, we have to provide .yml files for each language and in those language-specific .yml, we have to provide a map of key-value pairs where the key is the id of the string and value is the string in that particular language. By default the language or locale is set to be English(:en). &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
THE GREATEST BENEFITS of using this library are - &amp;lt;br&amp;gt;&lt;br /&gt;
*The strings aren't hardcoded in the code/build. The strings are being fetched from external files which can be easily modified. For example, if one needs to change the text from 'Please Help' to 'Help', then one just needs to make a change in the .yml file and the change would reflect on the browser. For this change, we didn't need to redeploy the server. We just Decoupled the view when and where from what content is to be shown. &lt;br /&gt;
*Adding more languages is now super easy. Adding support for another language is just one line change in the config and adding a .yml file (having all the key-value pairs for the strings) for the new language. By doing this we can extend the language support as much as we want.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''''3. Translation gaps'''''&lt;br /&gt;
&amp;lt;br&amp;gt;Also, if the language is set to be Hindi or any other language but the key-value pair is not set for that particular string then, automatically the library returns the default which is the English text.&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;config.i18n.fallbacks = [:en]&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Alternate approaches ==&lt;br /&gt;
&lt;br /&gt;
'''1. Why not simply swap out the entire view for another language instead of each text?'''&amp;lt;br&amp;gt;&lt;br /&gt;
A view is an organized collection of multiple separate elements, views often involve dynamic generation and some level of sophistication. If we were to swap out one page in its entirety for another page this would often violate the '''DRY''' principle since we would have to have two separate implementations of the view in each language. Thus in the worst case, you have a complex view that has to be replicated dozens of times in various languages.&lt;br /&gt;
The majority of complexity of the page is not in the content itself but rather the code that executes to generate that content, thus it makes sense to instead maintain a single view and embed the language switching logic at each location where translation needs to occur to avoid replication of everything around it.&lt;br /&gt;
&lt;br /&gt;
'''2. Why did we pick i18n over implementing it ourselves?'''&amp;lt;br&amp;gt;&lt;br /&gt;
Doing it ourselves felt like a great option. But i18n not just selects a language string at runtime for us it does a lot more under the hood which makes our lives easier. For example, it manages locale over the session for us, even if we change the urls and shift tabs and other stuff it manages our locale. &amp;lt;br&amp;gt;&lt;br /&gt;
Also there is a great principle that says - “ If it isn’t broken, Don’t fix it”. The library manages the registering of different language yml files, points to the right right text at runtime, manages session locale and a lot more. So we want to explore this library instead of reimplementing the same thing again.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''3, Why did we store the default language choices in database instead of in session?'''&amp;lt;br&amp;gt;&lt;br /&gt;
We had to decide on whether to keep the student’s language preference in the database or in the session. We have thought about both approaches and below listed are the advantages and disadvantages.&lt;br /&gt;
&lt;br /&gt;
In the work done by the previous team, they added a dropdown in the navbar where a student can choose the preferred language. One of the changes that we did was to move this field to the user profile page. The earlier team used session storage to store the preferred language. This session resets on every logout, but since the preferred language can easily be set from any page this wasn't much of an issue.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Storing user language preference in database.&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	If we are moving the language preference field to the user profile page, it will create some user experience issues if the preference is stored in session. The student will have to visit the user profile page every time they log in. To avoid this scenario, it’s better to keep the language preference in the database, so that the preference stays saved across sessions.&lt;br /&gt;
	The disadvantage of moving the language preference to the database is that it brings forth a schema change and this always requires a very careful going through to ensure that nothing else is affected. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Storing language preference in session storage.&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The main advantage of storing the language preference in session storage is that no schema change is involved. This decreases the chance of other features being affected. The main disadvantage is that the student will have to go to the user profile page every time they log in to set the preference, causing a user experience issue. Keep in mind that we’re moving the field away from the navbar to a user profile page.&lt;br /&gt;
&lt;br /&gt;
After considering these points, we finally decided to go store the user preference in the database itself as the project requires us to add a language preference field in user profile page.&lt;br /&gt;
&lt;br /&gt;
== Use Case Diagram ==&lt;br /&gt;
&amp;lt;li&amp;gt;An instructor can add a default language to any course. English is the default choice.&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;The user has an option to change their preferred language at any time. They have the option to do so in their profile page. &amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;All pages including the course-related and non-course-related pages are displayed in the user preferred language for any user other than student&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Every non-course-related page is displayed in the student’s preferred language. Keys for which a translation is not found are displayed in the default language that is English&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Every course-related page is displayed in the student’s preferred language. If the student doesn’t have a preferred language, the course is displayed in the course’s preferred language. Keys for which a translation is not found are displayed in the default language that is English.&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:usecasediagram.png|2000px|865px]]&lt;br /&gt;
&lt;br /&gt;
== Major design patterns and principles used ==&lt;br /&gt;
&lt;br /&gt;
'''1. DRY: The i18n ‘t’ function'''&amp;lt;br&amp;gt;&lt;br /&gt;
We observe an extreme case of DRY with the t function of i18n.&lt;br /&gt;
For some background, the t function of the library takes in a key representing a text and returns the content referred to by that key in the preferred language of the user. It also performs many other functions such as falling back to a backup language if the translation for the preferred language has not been configured for that specific key. Thus since this logic has to be applied at every element of the view, it would behove us to extract this logic into a reusable function which is what the designers of the i18n library have employed&lt;br /&gt;
&lt;br /&gt;
'''2. Chain of responsibility'''&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Chainofresp.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The I18n library gives us an option to have many fall back options. When the required text for a given language is not found, we then move on to find the text for the next language in the chain and so on until we find it. And in the end we will put english as default language. So if the key value pair for the text is not found in none of the yml files then the text will be fetched from the English language yml file.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''3. Open closed principle &amp;amp; Strategy Pattern'''&amp;lt;br&amp;gt;&lt;br /&gt;
As discussed in the “Language selection&amp;quot; design proposal above, if the user has not selected a preferred language, we do not simply default the view to render in the application language (English). Instead, the project requirements state that for course specific screens such as the assignment view, we would need to render the view in the course’s language.&lt;br /&gt;
While we could implement this code into the application controller that checks the controller being access and accordingly applies overrides on the default language, this violates the open closed principle since we would need to extend this logic any time we introduce a new course specific screen. Instead a better approach is to delegate the decision of selecting the language to the view itself since the view would be most aware of whether the view is course specific or not. We can also preserve the DRYness through mix-ins.&lt;br /&gt;
&lt;br /&gt;
== Database Design ==&lt;br /&gt;
We add the locale field to the users and courses tables which has the default values 0 and 1, which is no preference and en_US respectively.&lt;br /&gt;
&lt;br /&gt;
The migrations will look as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class AddLangLocaleToUsers &amp;lt; ActiveRecord::Migration&lt;br /&gt;
  def change&lt;br /&gt;
    add_column :users, :locale, :integer, default: 0&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class AddLocaleToCourses &amp;lt; ActiveRecord::Migration&lt;br /&gt;
  def change&lt;br /&gt;
    add_column :courses, :locale, :integer, default: 1&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Database Modification ==&lt;br /&gt;
We add a new integer field to the users table to store the user preferred language. The integer will be hashed to the supported languages. The default value in the table will be 0, which will be no_pref.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
enum locale: {&lt;br /&gt;
      no_pref: 0,&lt;br /&gt;
      en_US: 1,&lt;br /&gt;
      hi_IN: 2&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We also add a new integer field to the courses table to store the course preferred language. The integer will be hashed to the supported languages. The default value in the table will be 1, which will be en_US.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
enum locale: {&lt;br /&gt;
      en_US: 1,&lt;br /&gt;
      hi_IN: 2&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Hence the updated courses table will look like following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
create_table &amp;quot;courses&amp;quot;, force: :cascade do |t|&lt;br /&gt;
    t.string   &amp;quot;name&amp;quot;,            limit: 255&lt;br /&gt;
    t.integer  &amp;quot;instructor_id&amp;quot;,   limit: 4&lt;br /&gt;
    t.string   &amp;quot;directory_path&amp;quot;,  limit: 255&lt;br /&gt;
    t.text     &amp;quot;info&amp;quot;,            limit: 65535&lt;br /&gt;
    t.datetime &amp;quot;created_at&amp;quot;&lt;br /&gt;
    t.datetime &amp;quot;updated_at&amp;quot;&lt;br /&gt;
    t.boolean  &amp;quot;private&amp;quot;,                       default: false, null: false&lt;br /&gt;
    t.integer  &amp;quot;institutions_id&amp;quot;, limit: 4&lt;br /&gt;
    t.integer  &amp;quot;locale&amp;quot;,          limit: 4,     default: 1&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
While the updated users table will look like the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
create_table &amp;quot;users&amp;quot;, force: :cascade do |t|&lt;br /&gt;
    t.string  &amp;quot;name&amp;quot;,                      limit: 255,      default: &amp;quot;&amp;quot;,    null: false&lt;br /&gt;
    t.string  &amp;quot;crypted_password&amp;quot;,          limit: 40,       default: &amp;quot;&amp;quot;,    null: false&lt;br /&gt;
    t.integer &amp;quot;role_id&amp;quot;,                   limit: 4,        default: 0,     null: false&lt;br /&gt;
    t.string  &amp;quot;password_salt&amp;quot;,             limit: 255&lt;br /&gt;
    t.string  &amp;quot;fullname&amp;quot;,                  limit: 255&lt;br /&gt;
    t.string  &amp;quot;email&amp;quot;,                     limit: 255&lt;br /&gt;
    t.integer &amp;quot;parent_id&amp;quot;,                 limit: 4&lt;br /&gt;
    t.boolean &amp;quot;private_by_default&amp;quot;,                         default: false&lt;br /&gt;
    t.string  &amp;quot;mru_directory_path&amp;quot;,        limit: 128&lt;br /&gt;
    t.boolean &amp;quot;email_on_review&amp;quot;&lt;br /&gt;
    t.boolean &amp;quot;email_on_submission&amp;quot;&lt;br /&gt;
    t.boolean &amp;quot;email_on_review_of_review&amp;quot;&lt;br /&gt;
    t.boolean &amp;quot;is_new_user&amp;quot;,                                default: true,  null: false&lt;br /&gt;
    t.integer &amp;quot;master_permission_granted&amp;quot;, limit: 1,        default: 0&lt;br /&gt;
    t.string  &amp;quot;handle&amp;quot;,                    limit: 255&lt;br /&gt;
    t.text    &amp;quot;digital_certificate&amp;quot;,       limit: 16777215&lt;br /&gt;
    t.string  &amp;quot;persistence_token&amp;quot;,         limit: 255&lt;br /&gt;
    t.string  &amp;quot;timezonepref&amp;quot;,              limit: 255&lt;br /&gt;
    t.text    &amp;quot;public_key&amp;quot;,                limit: 16777215&lt;br /&gt;
    t.boolean &amp;quot;copy_of_emails&amp;quot;,                             default: false&lt;br /&gt;
    t.integer &amp;quot;institution_id&amp;quot;,            limit: 4&lt;br /&gt;
    t.boolean &amp;quot;preference_home_flag&amp;quot;,                       default: true&lt;br /&gt;
    t.integer &amp;quot;locale&amp;quot;,                    limit: 4,        default: 0&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The locale field is the last column on both tables:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    courses:&amp;gt; t.integer  &amp;quot;locale&amp;quot;,  limit: 4,    default: 1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
      users:&amp;gt; t.integer &amp;quot;locale&amp;quot;,   limit: 4,    default: 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
===Manual Testing===&lt;br /&gt;
&lt;br /&gt;
Through manual testing, we aim to identify if all the features of the application are working as intended when the language conversion occurs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Scenario 1&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Log in to Expertiza as a student.&lt;br /&gt;
&lt;br /&gt;
2. Go to the “User Profile Information” page and change “Preferred Language” to Hindi.&lt;br /&gt;
&lt;br /&gt;
3. Check to see if the English strings on the profile page are translated to Hindi.&lt;br /&gt;
&lt;br /&gt;
4. Check if a page for which Hindi translation keys are added has its English static strings translated to Hindi.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Scenario 2&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Log in to Expertiza as a student.&lt;br /&gt;
&lt;br /&gt;
2. Go to the “User Profile Information” page and change “Preferred Language” to No Preferences.&lt;br /&gt;
&lt;br /&gt;
3.  Check to see if the English strings on the page are unchanged, as the “User Profile Information” translates only if the student has a preference.&lt;br /&gt;
&lt;br /&gt;
4. Go to an assignment page for which Hindi translation keys are added, which is under a course with the default language set to Hindi, and check whether the English strings are translated to Hindi.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Scenario 3&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Log in to Expertiza as a student.&lt;br /&gt;
&lt;br /&gt;
2. Go to the “User Profile Information” page and change “Preferred Language” to Nil.&lt;br /&gt;
&lt;br /&gt;
3.  Check to see if the English strings on the page are unchanged, as the “User Profile Information” translates only if the student has a preference.&lt;br /&gt;
&lt;br /&gt;
4. Go to a non-course-specific page and verify that the page is displayed in English itself, as non of the default languages set for any of the courses should have any role.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Scenario 4&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Log in to Expertiza as a student.&lt;br /&gt;
&lt;br /&gt;
2. Go to the “User Profile Information” page and change “Preferred Language” to Hindi.&lt;br /&gt;
&lt;br /&gt;
3.  Go to a page where translation keys aren’t added completely and make sure that the unspecified keys display strings in English as a fallback.&lt;br /&gt;
&lt;br /&gt;
== Future Scope==&lt;br /&gt;
'''1. Expand to more languages'''&amp;lt;br&amp;gt;&lt;br /&gt;
As part of this project we have targetted Hindi as a second language, however our work makes it easy to extend to other languages as well.&lt;br /&gt;
&lt;br /&gt;
'''2. Identify and implement the course language override on more course specific screens'''&amp;lt;br&amp;gt;&lt;br /&gt;
As part of this project, we have introduced a generic framework by which any view can provide a preferred language in which it should be rendered, this is required by this project for the course language feature set by the instructor.&lt;br /&gt;
We have currently most course specific pages translated according to course language preference when the user has not provided any preference, but we need to identify if we have left out any other course specific page and add those to the list of pages which should take the course language setting into consideration.&lt;br /&gt;
&lt;br /&gt;
== Team ==&lt;br /&gt;
&lt;br /&gt;
'''Team Members'''&lt;br /&gt;
&lt;br /&gt;
Reuben M. V. John [[mailto:rmjohn2@ncsu.edu rmjohn2@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Renji Joseph Sabu [[mailto:rsabu@ncsu.edu rsabu@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Ashwin Das [[mailto:adas9@ncsu.edu adas9@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Arnav Julka [[mailto:ajulka@ncsu.edu ajulka@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Mentor'''&lt;br /&gt;
&lt;br /&gt;
Jialin Cui [[mailto:jcui9@ncsu.edu jcui9@ncsu.edu]]&lt;/div&gt;</summary>
		<author><name>Ajulka</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization&amp;diff=142381</id>
		<title>CSC/ECE 517 Fall 2021 - E2159. Expertiza internationalization</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization&amp;diff=142381"/>
		<updated>2021-11-30T06:35:40Z</updated>

		<summary type="html">&lt;p&gt;Ajulka: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Important Links ==&lt;br /&gt;
Git PR - https://github.com/expertiza/expertiza/pull/2151&lt;br /&gt;
Git beta branch - https://github.com/arnavjulka/expertiza/tree/beta&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Introduction - Purpose &amp;amp; Problem ==&lt;br /&gt;
&lt;br /&gt;
Currently, all Expertiza screens can only be viewed in English. Many Expertiza users are from other countries. This is a problem since this limits the accessibility of Expertiza. An important step in solving this problem is by making Expertiza available in more languages, which is a form of internationalization.&lt;br /&gt;
W3C defines [https://www.w3.org/International/questions/qa-i18n internationalization] as “''the design and development of a product, application or document content that enables easy localization for target audiences that vary in culture, region, or language.''”&lt;br /&gt;
&lt;br /&gt;
[[File:country_pie.png|none|500px|]]&amp;lt;br&amp;gt;&lt;br /&gt;
Survey of home country of Expertiza users for a given course&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Scope:''' The scope of this project is limited however only to static strings. i.e. user-generated content will not be automatically translated to other languages.&lt;br /&gt;
&lt;br /&gt;
'''Breaking down internationalization into 3 sequential subproblems:'''&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Twophase2.jpg|none|700px]]&amp;lt;br&amp;gt;&lt;br /&gt;
'''1. Language selection'''&amp;lt;br&amp;gt;&lt;br /&gt;
Every user has an option to set a language preference in the User Profile Information Edit page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:ProfileEditPage.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
There is also an option where the instructor can choose a default language for a course. &lt;br /&gt;
&lt;br /&gt;
[[File:language2inter.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Thus, the language not only varies from user to user but also across screens for the same user. Thus we need to recompute the language in which the page is to be rendered. If the student has given a language preference, then the choice is given weightage over the course default language chosen by the instructor. &lt;br /&gt;
&lt;br /&gt;
'''2. Rendering the language'''&amp;lt;br&amp;gt;&lt;br /&gt;
'''How do we go about rendering the screen in that language?''' &amp;lt;br&amp;gt;&lt;br /&gt;
In the previous step, we’ve identified the language in which a view is to be rendered. It is important to note that this language may not only differ for a different user, but also for a different page for the same user. The question now becomes, how do we render the screen in this language?&amp;lt;br&amp;gt;&lt;br /&gt;
To tackle this question, we explore 2 fundamental concepts:&amp;lt;br&amp;gt;&lt;br /&gt;
'''2.1 Views are composed of independent language elements'''&amp;lt;br&amp;gt;&lt;br /&gt;
While this is something we typically take for granted, it becomes especially important in the context of translation. That is, a view is not a single contiguous block of text, nor is it an atomic visualization of information (unlike a screenshot), but rather a carefully organized collection of individual elements such as texts, buttons, etc that each contain language that needs to be translated separately. Crucially, this means that we cannot swap out a page in one language in its entirety for a page in another language in its entirety. Instead, each individual element needs to be swapped out individually so as to only impact the language and not the structural composition of the page itself.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''2.2 Views require translation at a large number of call sites'''&amp;lt;br&amp;gt;&lt;br /&gt;
Given that a view is composed of individual elements, this also means that the computation of how to translate such an element such as a button’s text would need to be done separately for each element. This would result in not only a single centralized &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''3. Translation gaps'''&lt;br /&gt;
&lt;br /&gt;
What if the translation for the target language is not available?&lt;br /&gt;
Even translation for a language like Hindi may be available in general, the translation for a given text may not be available Hindi. This may be due to a variety of reasons:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
The specific text may have been accidentally missed out (remember the translation is not being done at runtime through an API, but rather curated by the developer)&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
The given text is non-trivial to translate to the target language&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
Our design would thus need to accommodate this by seamlessly falling back on another language whose translation is available.&lt;br /&gt;
&lt;br /&gt;
== Scope ==&lt;br /&gt;
The scope of this project is limited however only to static strings. I.e. user-generated content will not be automatically translated to other languages.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
'''Proposed Solution''' &amp;lt;br&amp;gt;&lt;br /&gt;
We explore and solve each of the three problems above in isolation:&lt;br /&gt;
&lt;br /&gt;
'''''1. Language selection'''''&amp;lt;br&amp;gt;&lt;br /&gt;
The language in which the page is rendered depends on a set of conditions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;If the user has set a language preference all pages are displayed in that language.&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;If the user has not set a language preference and the user is an instructor, all the pages are displayed in English.&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;If the user has not set a language preference and the user is a student who is on a page that is specific to a course for which the instructor has added a default language, the page is displayed in the course’s default language.&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The below functions are added and called before page rendering to bring in this logic.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  before_action :set_locale&lt;br /&gt;
&lt;br /&gt;
  def set_locale&lt;br /&gt;
    # Checks whether the user is logged in, else the default locale is used&lt;br /&gt;
    if logged_in?&lt;br /&gt;
      # If the current user has set his preferred language, the locale is set according to their preference&lt;br /&gt;
      if @current_user.locale != &amp;quot;no_pref&amp;quot;&lt;br /&gt;
        I18n.locale = @current_user.locale&lt;br /&gt;
        # If the user doesn't have any preference, the locale is taken from the course locale, if the current page is a course specific page or else default locale is used&lt;br /&gt;
      elsif current_user_role? &amp;amp;&amp;amp; current_user_role.student? &amp;amp;&amp;amp; [&amp;quot;student_task&amp;quot;, &amp;quot;sign_up_sheet&amp;quot;, &amp;quot;student_teams&amp;quot;, &amp;quot;student_review&amp;quot;, &amp;quot;grades&amp;quot;, &amp;quot;submitted_content&amp;quot;, &amp;quot;participants&amp;quot;].include?(params[:controller])&lt;br /&gt;
        set_new_locale_for_student&lt;br /&gt;
      else&lt;br /&gt;
        I18n.locale = I18n.default_locale&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      I18n.locale = I18n.default_locale&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def set_new_locale_for_student&lt;br /&gt;
    # Gets participant using student from params&lt;br /&gt;
    if !params[:id].nil? || !params[:student_id].nil?&lt;br /&gt;
      participant_id = params[:id] || params[:student_id]&lt;br /&gt;
      participant = AssignmentParticipant.find_by(id: participant_id)&lt;br /&gt;
      # If id or student_id not correct, revert to locale based on courses.&lt;br /&gt;
      if participant.nil?&lt;br /&gt;
        find_locale_from_courses&lt;br /&gt;
        return&lt;br /&gt;
      end&lt;br /&gt;
      # Find assignment from participant and find locale from the assigment&lt;br /&gt;
      assignment = participant.assignment&lt;br /&gt;
      if !assignment.course.nil?&lt;br /&gt;
        new_locale = assignment.course.locale&lt;br /&gt;
        if !new_locale.nil?&lt;br /&gt;
          I18n.locale = new_locale&lt;br /&gt;
        else&lt;br /&gt;
          I18n.locale = I18n.default_locale&lt;br /&gt;
        end&lt;br /&gt;
      else&lt;br /&gt;
        I18n.locale = I18n.default_locale&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      find_locale_from_courses&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def find_locale_from_courses&lt;br /&gt;
    # If the page is a course or assignment page with no specific student id, every course of that student is checked and if&lt;br /&gt;
    # the language for all these course are same, the page is displayed in that language&lt;br /&gt;
  courseParticipants = CourseParticipant.where(user_id: current_user.id)&lt;br /&gt;
    courseParticipantsLocales = courseParticipants.map { |cp| cp.course.locale }&lt;br /&gt;
    # If no tasks, then possible to have no courses assigned.&lt;br /&gt;
    if courseParticipantsLocales.uniq.length == 1 #&amp;amp;&amp;amp; !@tasks.empty?&lt;br /&gt;
      course = courseParticipants.first.course&lt;br /&gt;
      if course.locale?&lt;br /&gt;
        I18n.locale = course.locale&lt;br /&gt;
      else&lt;br /&gt;
        I18n.locale = I18n.default_locale&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      I18n.locale = I18n.default_locale&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;If the student user has not set a language preference and is not on a course-specific page, then the page is displayed in English.&lt;br /&gt;
If a language preference is obtained by following the above conditions but some keys in the page don't have a translation for the language, the English translation for that key is returned as a fallback.&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''''2. Rendering the language'''''&amp;lt;br&amp;gt;&lt;br /&gt;
Once we have determined the language in which to render the page, we now need to update the rails view code to actually generate the appropriate HTML in the target language. This is the responsibility of the view. However, currently, the actual content of the HTML is hardcoded in (red) English. For example:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;Summary Report for assignment: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;Team: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
As discussed earlier, “Views are composed of independent language elements” and so we cannot simply swap out the entire page content for a separate page in another language (Why? - See “swap out the entire view” in the alternative approaches section):&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;Rapport de synthèse pour l'affectation: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;Équipe: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;Instead, the better approach is to have a single unified view that dynamically changes based on the selected language:&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;&amp;lt;%=language==’en’ ? ‘Summary Report for assignment’ : ‘Rapport de synthèse pour l'affectation’&amp;gt;: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;&amp;lt;%=language==’en’ ? ‘Team’ : ‘Équipe’&amp;gt;: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;However this is clearly infeasible considering the number of call sites where we have to apply this logic. Thus, in order to maximize how concise the call site is, we can pull out this logic into a common helper function:&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;&amp;lt;%=localized(“report_summary.page_header”)&amp;gt;: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;&amp;lt;%=localized(“report_summary.team_label”)&amp;gt;: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;Here the assumption is that the localized(“key”) is aware of the currently selected language and that “report_summary.page_header” is the key for the header which is available in English and Hindi. The helper intelligently selects and returns the right text based on the currently selected language. Through this approach, we are able to render the view in multiple possible languages without any significant increase in the verbosity of the view.&lt;br /&gt;
&lt;br /&gt;
What’s more, is that the above problem is a common problem for user-facing applications and a standard library for doing the above and much more already exists for rails applications called i18n&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''''I18n - Internationalisation, How are we using I18n in Ruby on Rail'''''&amp;lt;br&amp;gt;&lt;br /&gt;
I18n is a ruby library/gem which helps us render the static string on the view dynamically. Dynamicity means that based on a local decision of choosing the current language of the view, the library returns the strings of that particular language at runtime.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
These strings, instead of hardcoding in the view.rb, are provided in external .yml files. Now at the View level, we can pass an id to the 't' function and the I18n library returns the string for that id of the current set language(called as locale). &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:i18n.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
For this purpose, we have to provide .yml files for each language and in those language-specific .yml, we have to provide a map of key-value pairs where the key is the id of the string and value is the string in that particular language. By default the language or locale is set to be English(:en). &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
THE GREATEST BENEFITS of using this library are - &amp;lt;br&amp;gt;&lt;br /&gt;
*The strings aren't hardcoded in the code/build. The strings are being fetched from external files which can be easily modified. For example, if one needs to change the text from 'Please Help' to 'Help', then one just needs to make a change in the .yml file and the change would reflect on the browser. For this change, we didn't need to redeploy the server. We just Decoupled the view when and where from what content is to be shown. &lt;br /&gt;
*Adding more languages is now super easy. Adding support for another language is just one line change in the config and adding a .yml file (having all the key-value pairs for the strings) for the new language. By doing this we can extend the language support as much as we want.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''''3. Translation gaps'''''&lt;br /&gt;
&amp;lt;br&amp;gt;Also, if the language is set to be Hindi or any other language but the key-value pair is not set for that particular string then, automatically the library returns the default which is the English text.&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;config.i18n.fallbacks = [:en]&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Alternate approaches ==&lt;br /&gt;
&lt;br /&gt;
'''1. Why not simply swap out the entire view for another language instead of each text?'''&amp;lt;br&amp;gt;&lt;br /&gt;
A view is an organized collection of multiple separate elements, views often involve dynamic generation and some level of sophistication. If we were to swap out one page in its entirety for another page this would often violate the '''DRY''' principle since we would have to have two separate implementations of the view in each language. Thus in the worst case, you have a complex view that has to be replicated dozens of times in various languages.&lt;br /&gt;
The majority of complexity of the page is not in the content itself but rather the code that executes to generate that content, thus it makes sense to instead maintain a single view and embed the language switching logic at each location where translation needs to occur to avoid replication of everything around it.&lt;br /&gt;
&lt;br /&gt;
'''2. Why did we pick i18n over implementing it ourselves?'''&amp;lt;br&amp;gt;&lt;br /&gt;
Doing it ourselves felt like a great option. But i18n not just selects a language string at runtime for us it does a lot more under the hood which makes our lives easier. For example, it manages locale over the session for us, even if we change the urls and shift tabs and other stuff it manages our locale. &amp;lt;br&amp;gt;&lt;br /&gt;
Also there is a great principle that says - “ If it isn’t broken, Don’t fix it”. The library manages the registering of different language yml files, points to the right right text at runtime, manages session locale and a lot more. So we want to explore this library instead of reimplementing the same thing again.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''3, Why did we store the default language choices in database instead of in session?'''&amp;lt;br&amp;gt;&lt;br /&gt;
We had to decide on whether to keep the student’s language preference in the database or in the session. We have thought about both approaches and below listed are the advantages and disadvantages.&lt;br /&gt;
&lt;br /&gt;
In the work done by the previous team, they added a dropdown in the navbar where a student can choose the preferred language. One of the changes that we did was to move this field to the user profile page. The earlier team used session storage to store the preferred language. This session resets on every logout, but since the preferred language can easily be set from any page this wasn't much of an issue.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Storing user language preference in database.&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	If we are moving the language preference field to the user profile page, it will create some user experience issues if the preference is stored in session. The student will have to visit the user profile page every time they log in. To avoid this scenario, it’s better to keep the language preference in the database, so that the preference stays saved across sessions.&lt;br /&gt;
	The disadvantage of moving the language preference to the database is that it brings forth a schema change and this always requires a very careful going through to ensure that nothing else is affected. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Storing language preference in session storage.&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The main advantage of storing the language preference in session storage is that no schema change is involved. This decreases the chance of other features being affected. The main disadvantage is that the student will have to go to the user profile page every time they log in to set the preference, causing a user experience issue. Keep in mind that we’re moving the field away from the navbar to a user profile page.&lt;br /&gt;
&lt;br /&gt;
After considering these points, we finally decided to go store the user preference in the database itself as the project requires us to add a language preference field in user profile page.&lt;br /&gt;
&lt;br /&gt;
== Use Case Diagram ==&lt;br /&gt;
&amp;lt;li&amp;gt;An instructor can add a default language to any course. English is the default choice.&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;The user has an option to change their preferred language at any time. They have the option to do so in their profile page. &amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;All pages including the course-related and non-course-related pages are displayed in the user preferred language for any user other than student&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Every non-course-related page is displayed in the student’s preferred language. Keys for which a translation is not found are displayed in the default language that is English&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Every course-related page is displayed in the student’s preferred language. If the student doesn’t have a preferred language, the course is displayed in the course’s preferred language. Keys for which a translation is not found are displayed in the default language that is English.&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:usecasediagram.png|2000px|865px]]&lt;br /&gt;
&lt;br /&gt;
== Major design patterns and principles used ==&lt;br /&gt;
&lt;br /&gt;
'''1. DRY: The i18n ‘t’ function'''&amp;lt;br&amp;gt;&lt;br /&gt;
We observe an extreme case of DRY with the t function of i18n.&lt;br /&gt;
For some background, the t function of the library takes in a key representing a text and returns the content referred to by that key in the preferred language of the user. It also performs many other functions such as falling back to a backup language if the translation for the preferred language has not been configured for that specific key. Thus since this logic has to be applied at every element of the view, it would behove us to extract this logic into a reusable function which is what the designers of the i18n library have employed&lt;br /&gt;
&lt;br /&gt;
'''2. Chain of responsibility'''&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Chainofresp.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The I18n library gives us an option to have many fall back options. When the required text for a given language is not found, we then move on to find the text for the next language in the chain and so on until we find it. And in the end we will put english as default language. So if the key value pair for the text is not found in none of the yml files then the text will be fetched from the English language yml file.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''3. Open closed principle &amp;amp; Strategy Pattern'''&amp;lt;br&amp;gt;&lt;br /&gt;
As discussed in the “Language selection&amp;quot; design proposal above, if the user has not selected a preferred language, we do not simply default the view to render in the application language (English). Instead, the project requirements state that for course specific screens such as the assignment view, we would need to render the view in the course’s language.&lt;br /&gt;
While we could implement this code into the application controller that checks the controller being access and accordingly applies overrides on the default language, this violates the open closed principle since we would need to extend this logic any time we introduce a new course specific screen. Instead a better approach is to delegate the decision of selecting the language to the view itself since the view would be most aware of whether the view is course specific or not. We can also preserve the DRYness through mix-ins.&lt;br /&gt;
&lt;br /&gt;
== Database Design ==&lt;br /&gt;
We add the locale field to the users and courses tables which has the default values 0 and 1, which is no preference and en_US respectively.&lt;br /&gt;
&lt;br /&gt;
The migrations will look as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class AddLangLocaleToUsers &amp;lt; ActiveRecord::Migration&lt;br /&gt;
  def change&lt;br /&gt;
    add_column :users, :locale, :integer, default: 0&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class AddLocaleToCourses &amp;lt; ActiveRecord::Migration&lt;br /&gt;
  def change&lt;br /&gt;
    add_column :courses, :locale, :integer, default: 1&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Database Modification ==&lt;br /&gt;
We add a new integer field to the users table to store the user preferred language. The integer will be hashed to the supported languages. The default value in the table will be 0, which will be no_pref.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
enum locale: {&lt;br /&gt;
      no_pref: 0,&lt;br /&gt;
      en_US: 1,&lt;br /&gt;
      hi_IN: 2&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We also add a new integer field to the courses table to store the course preferred language. The integer will be hashed to the supported languages. The default value in the table will be 1, which will be en_US.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
enum locale: {&lt;br /&gt;
      en_US: 1,&lt;br /&gt;
      hi_IN: 2&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Hence the updated courses table will look like following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
create_table &amp;quot;courses&amp;quot;, force: :cascade do |t|&lt;br /&gt;
    t.string   &amp;quot;name&amp;quot;,            limit: 255&lt;br /&gt;
    t.integer  &amp;quot;instructor_id&amp;quot;,   limit: 4&lt;br /&gt;
    t.string   &amp;quot;directory_path&amp;quot;,  limit: 255&lt;br /&gt;
    t.text     &amp;quot;info&amp;quot;,            limit: 65535&lt;br /&gt;
    t.datetime &amp;quot;created_at&amp;quot;&lt;br /&gt;
    t.datetime &amp;quot;updated_at&amp;quot;&lt;br /&gt;
    t.boolean  &amp;quot;private&amp;quot;,                       default: false, null: false&lt;br /&gt;
    t.integer  &amp;quot;institutions_id&amp;quot;, limit: 4&lt;br /&gt;
    t.integer  &amp;quot;locale&amp;quot;,          limit: 4,     default: 1&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
While the updated users table will look like the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
create_table &amp;quot;users&amp;quot;, force: :cascade do |t|&lt;br /&gt;
    t.string  &amp;quot;name&amp;quot;,                      limit: 255,      default: &amp;quot;&amp;quot;,    null: false&lt;br /&gt;
    t.string  &amp;quot;crypted_password&amp;quot;,          limit: 40,       default: &amp;quot;&amp;quot;,    null: false&lt;br /&gt;
    t.integer &amp;quot;role_id&amp;quot;,                   limit: 4,        default: 0,     null: false&lt;br /&gt;
    t.string  &amp;quot;password_salt&amp;quot;,             limit: 255&lt;br /&gt;
    t.string  &amp;quot;fullname&amp;quot;,                  limit: 255&lt;br /&gt;
    t.string  &amp;quot;email&amp;quot;,                     limit: 255&lt;br /&gt;
    t.integer &amp;quot;parent_id&amp;quot;,                 limit: 4&lt;br /&gt;
    t.boolean &amp;quot;private_by_default&amp;quot;,                         default: false&lt;br /&gt;
    t.string  &amp;quot;mru_directory_path&amp;quot;,        limit: 128&lt;br /&gt;
    t.boolean &amp;quot;email_on_review&amp;quot;&lt;br /&gt;
    t.boolean &amp;quot;email_on_submission&amp;quot;&lt;br /&gt;
    t.boolean &amp;quot;email_on_review_of_review&amp;quot;&lt;br /&gt;
    t.boolean &amp;quot;is_new_user&amp;quot;,                                default: true,  null: false&lt;br /&gt;
    t.integer &amp;quot;master_permission_granted&amp;quot;, limit: 1,        default: 0&lt;br /&gt;
    t.string  &amp;quot;handle&amp;quot;,                    limit: 255&lt;br /&gt;
    t.text    &amp;quot;digital_certificate&amp;quot;,       limit: 16777215&lt;br /&gt;
    t.string  &amp;quot;persistence_token&amp;quot;,         limit: 255&lt;br /&gt;
    t.string  &amp;quot;timezonepref&amp;quot;,              limit: 255&lt;br /&gt;
    t.text    &amp;quot;public_key&amp;quot;,                limit: 16777215&lt;br /&gt;
    t.boolean &amp;quot;copy_of_emails&amp;quot;,                             default: false&lt;br /&gt;
    t.integer &amp;quot;institution_id&amp;quot;,            limit: 4&lt;br /&gt;
    t.boolean &amp;quot;preference_home_flag&amp;quot;,                       default: true&lt;br /&gt;
    t.integer &amp;quot;locale&amp;quot;,                    limit: 4,        default: 0&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The locale field is the last column on both tables:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    courses:&amp;gt; t.integer  &amp;quot;locale&amp;quot;,  limit: 4,    default: 1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
      users:&amp;gt; t.integer &amp;quot;locale&amp;quot;,   limit: 4,    default: 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
===Manual Testing===&lt;br /&gt;
&lt;br /&gt;
Through manual testing, we aim to identify if all the features of the application are working as intended when the language conversion occurs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Scenario 1&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Log in to Expertiza as a student.&lt;br /&gt;
&lt;br /&gt;
2. Go to the “User Profile Information” page and change “Preferred Language” to Hindi.&lt;br /&gt;
&lt;br /&gt;
3. Check to see if the English strings on the profile page are translated to Hindi.&lt;br /&gt;
&lt;br /&gt;
4. Check if a page for which Hindi translation keys are added has its English static strings translated to Hindi.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Scenario 2&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Log in to Expertiza as a student.&lt;br /&gt;
&lt;br /&gt;
2. Go to the “User Profile Information” page and change “Preferred Language” to No Preferences.&lt;br /&gt;
&lt;br /&gt;
3.  Check to see if the English strings on the page are unchanged, as the “User Profile Information” translates only if the student has a preference.&lt;br /&gt;
&lt;br /&gt;
4. Go to an assignment page for which Hindi translation keys are added, which is under a course with the default language set to Hindi, and check whether the English strings are translated to Hindi.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Scenario 3&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Log in to Expertiza as a student.&lt;br /&gt;
&lt;br /&gt;
2. Go to the “User Profile Information” page and change “Preferred Language” to Nil.&lt;br /&gt;
&lt;br /&gt;
3.  Check to see if the English strings on the page are unchanged, as the “User Profile Information” translates only if the student has a preference.&lt;br /&gt;
&lt;br /&gt;
4. Go to a non-course-specific page and verify that the page is displayed in English itself, as non of the default languages set for any of the courses should have any role.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Scenario 4&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Log in to Expertiza as a student.&lt;br /&gt;
&lt;br /&gt;
2. Go to the “User Profile Information” page and change “Preferred Language” to Hindi.&lt;br /&gt;
&lt;br /&gt;
3.  Go to a page where translation keys aren’t added completely and make sure that the unspecified keys display strings in English as a fallback.&lt;br /&gt;
&lt;br /&gt;
== Future Scope==&lt;br /&gt;
'''1. Expand to more languages'''&amp;lt;br&amp;gt;&lt;br /&gt;
As part of this project we have targetted Hindi as a second language, however our work makes it easy to extend to other languages as well.&lt;br /&gt;
&lt;br /&gt;
'''2. Identify and implement the course language override on more course specific screens'''&amp;lt;br&amp;gt;&lt;br /&gt;
As part of this project, we have introduced a generic framework by which any view can provide a preferred language in which it should be rendered, this is required by this project for the course language feature set by the instructor.&lt;br /&gt;
We have currently most course specific pages translated according to course language preference when the user has not provided any preference, but we need to identify if we have left out any other course specific page and add those to the list of pages which should take the course language setting into consideration.&lt;br /&gt;
&lt;br /&gt;
== Team ==&lt;br /&gt;
&lt;br /&gt;
'''Team Members'''&lt;br /&gt;
&lt;br /&gt;
Reuben M. V. John [[mailto:rmjohn2@ncsu.edu rmjohn2@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Renji Joseph Sabu [[mailto:rsabu@ncsu.edu rsabu@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Ashwin Das [[mailto:adas9@ncsu.edu adas9@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Arnav Julka [[mailto:ajulka@ncsu.edu ajulka@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Mentor'''&lt;br /&gt;
&lt;br /&gt;
Jialin Cui [[mailto:jcui9@ncsu.edu jcui9@ncsu.edu]]&lt;/div&gt;</summary>
		<author><name>Ajulka</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization&amp;diff=140750</id>
		<title>CSC/ECE 517 Fall 2021 - E2159. Expertiza internationalization</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization&amp;diff=140750"/>
		<updated>2021-11-04T00:51:24Z</updated>

		<summary type="html">&lt;p&gt;Ajulka: /* Alternate approaches */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction - Purpose &amp;amp; Problem ==&lt;br /&gt;
&lt;br /&gt;
Currently, all Expertiza screens can only be viewed in English. Many Expertiza users are from other countries. This is a problem since this limits the accessibility of Expertiza. An important step in solving this problem is by making Expertiza available in more languages, which is a form of internationalization.&lt;br /&gt;
W3C defines [https://www.w3.org/International/questions/qa-i18n internationalization] as “''the design and development of a product, application or document content that enables easy localization for target audiences that vary in culture, region, or language.''”&lt;br /&gt;
&lt;br /&gt;
[[File:country_pie.png|none|500px|]]&amp;lt;br&amp;gt;&lt;br /&gt;
Survey of home country of Expertiza users for a given course&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Scope:''' The scope of this project is limited however only to static strings. i.e. user-generated content will not be automatically translated to other languages.&lt;br /&gt;
&lt;br /&gt;
'''Breaking down internationalization into 3 sequential subproblems:'''&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Twophase2.jpg|none|700px]]&amp;lt;br&amp;gt;&lt;br /&gt;
'''1. Language selection'''&amp;lt;br&amp;gt;&lt;br /&gt;
Internationalization is done for pages viewed by students only. Any user other than students views all pages in English. The student has the option to set a language preference.&lt;br /&gt;
&lt;br /&gt;
LOFI UI sketch&lt;br /&gt;
&lt;br /&gt;
[[File:language1inter.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
There is also an option where the instructor can choose a default language for a course. &lt;br /&gt;
&lt;br /&gt;
[[File:language2inter.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Thus, the language not only varies from user to user but also across screens for the same user. Thus we need to recompute the language in which the page is to be rendered. If the student has given a language preference, then the choice is given weightage over the default language chosen by the instructor. &lt;br /&gt;
&lt;br /&gt;
'''2. Rendering the language'''&amp;lt;br&amp;gt;&lt;br /&gt;
'''How do we go about rendering the screen in that language?''' &amp;lt;br&amp;gt;&lt;br /&gt;
In the previous step, we’ve identified the language in which a view is to be rendered. It is important to note that this language may not only differ for a different user, but also for a different page for the same user. The question now becomes, how do we render the screen in this language?&amp;lt;br&amp;gt;&lt;br /&gt;
To tackle this question, we explore 2 fundamental concepts:&amp;lt;br&amp;gt;&lt;br /&gt;
'''2.1 Views are composed of independent language elements'''&amp;lt;br&amp;gt;&lt;br /&gt;
While this is something we typically take for granted, it becomes especially important in the context of translation. That is, a view is not a single contiguous block of text, nor is it an atomic visualization of information (unlike a screenshot), but rather a carefully organized collection of individual elements such as texts, buttons, etc that each contain language that needs to be translated separately. Crucially, this means that we cannot swap out a page in one language in its entirety for a page in another language in its entirety. Instead, each individual element needs to be swapped out individually so as to only impact the language and not the structural composition of the page itself.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''2.2 Views require translation at a large number of call sites'''&amp;lt;br&amp;gt;&lt;br /&gt;
Given that a view is composed of individual elements, this also means that the computation of how to translate such an element such as a button’s text would need to be done separately for each element. This would result in not only a single centralized &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''3. Translation gaps'''&lt;br /&gt;
&lt;br /&gt;
What if the translation for the target language is not available?&lt;br /&gt;
Even translation for a language like Hindi may be available in general, the translation for a given text may not be available Hindi. This may be due to a variety of reasons:&lt;br /&gt;
The specific text may have been accidentally missed out (remember the translation is not being done at runtime through an API, but rather curated by the developer)&lt;br /&gt;
The given text is non-trivial to translate to the target language&lt;br /&gt;
Our design would thus need to accommodate this by seamlessly falling back on another language whose translation is available.&lt;br /&gt;
&lt;br /&gt;
== Scope ==&lt;br /&gt;
The scope of this project is limited however only to static strings. I.e. user-generated content will not be automatically translated to other languages.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
'''Proposed Solution''' &amp;lt;br&amp;gt;&lt;br /&gt;
We explore and solve each of the three problems above in isolation:&lt;br /&gt;
&lt;br /&gt;
'''''1. Language selection'''''&amp;lt;br&amp;gt;&lt;br /&gt;
The language in which the page is rendered depends on a set of conditions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;If the student has set a language preference, it overrides the default language setting saved by the instructor, and all pages are displayed in the language preferred by the student.&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;If the student has not set a language preference and is on a page that is specific to a course for which the instructor has added a default language, the page is displayed in the course’s default language.&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;If the student has not set a language preference and is not on a course-specific page, then the page is displayed in English.&lt;br /&gt;
If a language preference is obtained by following the above conditions but some keys in the page don't have a translation for the language, the English translation for that key is returned as a fallback.&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''''2. Rendering the language'''''&amp;lt;br&amp;gt;&lt;br /&gt;
Once we have determined the language in which to render the page, we now need to update the rails view code to actually generate the appropriate HTML in the target language. This is the responsibility of the view. However, currently, the actual content of the HTML is hardcoded in (red) English. For example:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;Summary Report for assignment: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;Team: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
As discussed earlier, “Views are composed of independent language elements” and so we cannot simply swap out the entire page content for a separate page in another language (Why? - See “swap out the entire view” in the alternative approaches section):&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;Rapport de synthèse pour l'affectation: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;Équipe: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;Instead, the better approach is to have a single unified view that dynamically changes based on the selected language:&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;&amp;lt;%=language==’en’ ? ‘Summary Report for assignment’ : ‘Rapport de synthèse pour l'affectation’&amp;gt;: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;&amp;lt;%=language==’en’ ? ‘Team’ : ‘Équipe’&amp;gt;: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;However this is clearly infeasible considering the number of call sites where we have to apply this logic. Thus, in order to maximize how concise the call site is, we can pull out this logic into a common helper function:&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;&amp;lt;%=localized(“report_summary.page_header”)&amp;gt;: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;&amp;lt;%=localized(“report_summary.team_label”)&amp;gt;: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;Here the assumption is that the localized(“key”) is aware of the currently selected language and that “report_summary.page_header” is the key for the header which is available in English and Hindi. The helper intelligently selects and returns the right text based on the currently selected language. Through this approach, we are able to render the view in multiple possible languages without any significant increase in the verbosity of the view.&lt;br /&gt;
&lt;br /&gt;
What’s more, is that the above problem is a common problem for user-facing applications and a standard library for doing the above and much more already exists for rails applications called i18n&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''''I18n - Internationalisation, How are we using I18n in Ruby on Rail'''''&amp;lt;br&amp;gt;&lt;br /&gt;
I18n is a ruby library/gem which helps us render the static string on the view dynamically. Dynamicity means that based on a local decision of choosing the current language of the view, the library returns the strings of that particular language at runtime.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
These strings, instead of hardcoding in the view.rb, are provided in external .yml files. Now at the View level, we can pass an id to the 't' function and the I18n library returns the string for that id of the current set language(called as locale). &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:i18n.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
For this purpose, we have to provide .yml files for each language and in those language-specific .yml, we have to provide a map of key-value pairs where the key is the id of the string and value is the string in that particular language. By default the language or locale is set to be English(:en). &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
THE GREATEST BENEFITS of using this library are - &amp;lt;br&amp;gt;&lt;br /&gt;
*The strings aren't hardcoded in the code/build. The strings are being fetched from external files which can be easily modified. For example, if one needs to change the text from 'Please Help' to 'Help', then one just needs to make a change in the .yml file and the change would reflect on the browser. For this change, we didn't need to redeploy the server. We just Decoupled the view when and where from what content is to be shown. &lt;br /&gt;
*Adding more languages is now super easy. Adding support for another language is just one line change in the config and adding a .yml file (having all the key-value pairs for the strings) for the new language. By doing this we can extend the language support as much as we want.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''''3. Translation gaps'''''&lt;br /&gt;
&amp;lt;br&amp;gt;Also, if the language is set to be Hindi or any other language but the key-value pair is not set for that particular string then, automatically the library returns the default which is the English text.&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;config.i18n.fallbacks = [:en]&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Alternate approaches ==&lt;br /&gt;
&lt;br /&gt;
'''1. Why not simply swap out the entire view for another language instead of each text?'''&amp;lt;br&amp;gt;&lt;br /&gt;
A view is an organized collection of multiple separate elements, views often involve dynamic generation and some level of sophistication. If we were to swap out one page in its entirety for another page this would often violate the '''DRY''' principle since we would have to have two separate implementations of the view in each language. Thus in the worst case, you have a complex view that has to be replicated dozens of times in various languages.&lt;br /&gt;
The majority of complexity of the page is not in the content itself but rather the code that executes to generate that content, thus it makes sense to instead maintain a single view and embed the language switching logic at each location where translation needs to occur to avoid replication of everything around it.&lt;br /&gt;
&lt;br /&gt;
'''2. Why did we pick i18n over implementing it ourselves?'''&amp;lt;br&amp;gt;&lt;br /&gt;
Doing it ourselves felt like a great option. But i18n not just selects a language string at runtime for us it does a lot more under the hood which makes our lives easier. For example, it manages locale over the session for us, even if we change the urls and shift tabs and other stuff it manages our locale. &amp;lt;br&amp;gt;&lt;br /&gt;
Also there is a great principle that says - “ If it isn’t broken, Don’t fix it”. The library manages the registering of different language yml files, points to the right right text at runtime, manages session locale and a lot more. So we want to explore this library instead of reimplementing the same thing again.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''3, Do we store the language preference, in the session or in the database?'''&amp;lt;br&amp;gt;&lt;br /&gt;
We are still deciding on whether to keep the student’s language preference in the database or in the session. We have thought about both approaches and below listed are the advantages and disadvantages.&lt;br /&gt;
&lt;br /&gt;
In the work done by the previous team, they added a dropdown in the navbar where a student can choose the preferred language. One of the changes that we intend to do is move this field to the user profile page. The earlier team used session storage to store the preferred language. This session resets on every logout, but since the preferred language can easily be set from any page this won’t be much of an issue.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Storing language preference in database.&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	If we are moving the language preference field to the user profile page, it will create some user experience issues if the preference is stored in session. The student will have to visit the user profile page every time they log in. To avoid this scenario, it’s better to keep the language preference in the database, so that the preference stays saved across sessions.&lt;br /&gt;
	The disadvantage of moving the language preference to the database is that it brings forth a schema change and this always requires a very careful going through to ensure that nothing else is affected. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Storing language preference in session storage.&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The main advantage of storing the language preference in session storage is that no schema change is involved. This decreases the chance of other features being affected. The main disadvantage is that the student will have to go to the user profile page every time they log in to set the preference, causing a user experience issue. Keep in mind that we’re moving the field away from the navbar to a user profile page.&lt;br /&gt;
&lt;br /&gt;
== Use Case Diagram ==&lt;br /&gt;
&amp;lt;li&amp;gt;An instructor can add a default language to any course. English is the default choice.&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;The student has an option to change their preferred language at any time. They have the option to do so in their profile page. &amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Every non-course-related page is displayed in the student’s preferred language. Keys for which a translation is not found are displayed in the default language that is English.&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Every course-related page is displayed in the student’s preferred language. If the student doesn’t have a preferred language, the course is displayed in the course’s preferred language. Keys for which a translation is not found are displayed in the default language that is English.&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:usecasediagram.png|2000px|865px]]&lt;br /&gt;
&lt;br /&gt;
== Major design patterns and principles used ==&lt;br /&gt;
&lt;br /&gt;
'''1. DRY: The i18n ‘t’ function'''&amp;lt;br&amp;gt;&lt;br /&gt;
We observe an extreme case of DRY with the t function of i18n.&lt;br /&gt;
For some background, the t function of the library takes in a key representing a text and returns the content referred to by that key in the preferred language of the user. It also performs many other functions such as falling back to a backup language if the translation for the preferred language has not been configured for that specific key. Thus since this logic has to be applied at every element of the view, it would behove us to extract this logic into a reusable function which is what the designers of the i18n library have employed&lt;br /&gt;
&lt;br /&gt;
'''2. Chain of responsibility'''&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Chainofresp.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The I18n library gives us an option to have many fall back options. When the required text for a given language is not found, we then move on to find the text for the next language in the chain and so on until we find it. And in the end we will put english as default language. So if the key value pair for the text is not found in none of the yml files then the text will be fetched from the English language yml file.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''3. Open closed principle &amp;amp; Strategy Pattern'''&amp;lt;br&amp;gt;&lt;br /&gt;
As discussed in the “Language selection&amp;quot; design proposal above, if the user has not selected a preferred language, we do not simply default the view to render in the application language (English). Instead, the project requirements state that for course specific screens such as the assignment view, we would need to render the view in the course’s language.&lt;br /&gt;
While we could implement this code into the application controller that checks the controller being access and accordingly applies overrides on the default language, this violates the open closed principle since we would need to extend this logic any time we introduce a new course specific screen. Instead a better approach is to delegate the decision of selecting the language to the view itself since the view would be most aware of whether the view is course specific or not. We can also preserve the DRYness through mix-ins.&lt;br /&gt;
&lt;br /&gt;
== Database Design ==&lt;br /&gt;
Currently, we are debating between keeping the language preference in the session or in the database. If we are going with the latter, we have to add a column in the users table.&lt;br /&gt;
&lt;br /&gt;
The migration will look as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;rails generate migration add_language_preference_to_users language_preference:string&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class AddLanguagePreferenceToUsers &amp;lt; ActiveRecord::Migration[5.0] &lt;br /&gt;
  def change &lt;br /&gt;
    add_column :users, :language_preference, :string &lt;br /&gt;
  end &lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Database Modification ==&lt;br /&gt;
The only need to update the users table if we are keeping the language preference in the DB.&lt;br /&gt;
The current schema of the “users” table is :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
create_table &amp;quot;users&amp;quot;, force: :cascade do |t|&lt;br /&gt;
   t.string  &amp;quot;name&amp;quot;,                      limit: 255,      default: &amp;quot;&amp;quot;,    null: false&lt;br /&gt;
   &lt;br /&gt;
   t.string  &amp;quot;crypted_password&amp;quot;,          limit: 40,       default: &amp;quot;&amp;quot;,    null: false&lt;br /&gt;
&lt;br /&gt;
   t.integer &amp;quot;role_id&amp;quot;,                   limit: 4,        default: 0,     null: false&lt;br /&gt;
&lt;br /&gt;
   t.string  &amp;quot;password_salt&amp;quot;,             limit: 255&lt;br /&gt;
&lt;br /&gt;
   t.string  &amp;quot;fullname&amp;quot;,                  limit: 255&lt;br /&gt;
&lt;br /&gt;
   t.string  &amp;quot;email&amp;quot;,                     limit: 255&lt;br /&gt;
&lt;br /&gt;
   t.integer &amp;quot;parent_id&amp;quot;,                 limit: 4&lt;br /&gt;
&lt;br /&gt;
   t.boolean &amp;quot;private_by_default&amp;quot;,                         default: false&lt;br /&gt;
&lt;br /&gt;
   t.string  &amp;quot;mru_directory_path&amp;quot;,        limit: 128&lt;br /&gt;
&lt;br /&gt;
   t.boolean &amp;quot;email_on_review&amp;quot;&lt;br /&gt;
&lt;br /&gt;
   t.boolean &amp;quot;email_on_submission&amp;quot;&lt;br /&gt;
&lt;br /&gt;
   t.boolean &amp;quot;email_on_review_of_review&amp;quot;&lt;br /&gt;
&lt;br /&gt;
   t.boolean &amp;quot;is_new_user&amp;quot;,                                default: true,  null: false&lt;br /&gt;
&lt;br /&gt;
   t.integer &amp;quot;master_permission_granted&amp;quot;, limit: 1,        default: 0&lt;br /&gt;
&lt;br /&gt;
   t.string  &amp;quot;handle&amp;quot;,                    limit: 255&lt;br /&gt;
&lt;br /&gt;
   t.text    &amp;quot;digital_certificate&amp;quot;,       limit: 16777215&lt;br /&gt;
&lt;br /&gt;
   t.string  &amp;quot;persistence_token&amp;quot;,         limit: 255&lt;br /&gt;
&lt;br /&gt;
   t.string  &amp;quot;timezonepref&amp;quot;,              limit: 255&lt;br /&gt;
&lt;br /&gt;
   t.text    &amp;quot;public_key&amp;quot;,                limit: 16777215&lt;br /&gt;
&lt;br /&gt;
   t.boolean &amp;quot;copy_of_emails&amp;quot;,                             default: false&lt;br /&gt;
&lt;br /&gt;
   t.integer &amp;quot;institution_id&amp;quot;,            limit: 4&lt;br /&gt;
&lt;br /&gt;
   t.boolean &amp;quot;preference_home_flag&amp;quot;,                       default: true&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Which will change to:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
create_table &amp;quot;users&amp;quot;, force: :cascade do |t|&lt;br /&gt;
   t.string  &amp;quot;name&amp;quot;,                      limit: 255,      default: &amp;quot;&amp;quot;,    null: false&lt;br /&gt;
   &lt;br /&gt;
   t.string  &amp;quot;crypted_password&amp;quot;,          limit: 40,       default: &amp;quot;&amp;quot;,    null: false&lt;br /&gt;
&lt;br /&gt;
   t.integer &amp;quot;role_id&amp;quot;,                   limit: 4,        default: 0,     null: false&lt;br /&gt;
&lt;br /&gt;
   t.string  &amp;quot;password_salt&amp;quot;,             limit: 255&lt;br /&gt;
&lt;br /&gt;
   t.string  &amp;quot;fullname&amp;quot;,                  limit: 255&lt;br /&gt;
&lt;br /&gt;
   t.string  &amp;quot;email&amp;quot;,                     limit: 255&lt;br /&gt;
&lt;br /&gt;
   t.integer &amp;quot;parent_id&amp;quot;,                 limit: 4&lt;br /&gt;
&lt;br /&gt;
   t.boolean &amp;quot;private_by_default&amp;quot;,                         default: false&lt;br /&gt;
&lt;br /&gt;
   t.string  &amp;quot;mru_directory_path&amp;quot;,        limit: 128&lt;br /&gt;
&lt;br /&gt;
   t.boolean &amp;quot;email_on_review&amp;quot;&lt;br /&gt;
&lt;br /&gt;
   t.boolean &amp;quot;email_on_submission&amp;quot;&lt;br /&gt;
&lt;br /&gt;
   t.boolean &amp;quot;email_on_review_of_review&amp;quot;&lt;br /&gt;
&lt;br /&gt;
   t.boolean &amp;quot;is_new_user&amp;quot;,                                default: true,  null: false&lt;br /&gt;
&lt;br /&gt;
   t.integer &amp;quot;master_permission_granted&amp;quot;, limit: 1,        default: 0&lt;br /&gt;
&lt;br /&gt;
   t.string  &amp;quot;handle&amp;quot;,                    limit: 255&lt;br /&gt;
&lt;br /&gt;
   t.text    &amp;quot;digital_certificate&amp;quot;,       limit: 16777215&lt;br /&gt;
&lt;br /&gt;
   t.string  &amp;quot;persistence_token&amp;quot;,         limit: 255&lt;br /&gt;
&lt;br /&gt;
   t.string  &amp;quot;timezonepref&amp;quot;,              limit: 255&lt;br /&gt;
&lt;br /&gt;
   t.text    &amp;quot;public_key&amp;quot;,                limit: 16777215&lt;br /&gt;
&lt;br /&gt;
   t.boolean &amp;quot;copy_of_emails&amp;quot;,                             default: false&lt;br /&gt;
&lt;br /&gt;
   t.integer &amp;quot;institution_id&amp;quot;,            limit: 4&lt;br /&gt;
&lt;br /&gt;
   t.boolean &amp;quot;preference_home_flag&amp;quot;,                       default: true&lt;br /&gt;
&lt;br /&gt;
   t.string “language_preference”,        limit: 255&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
===Manual Testing===&lt;br /&gt;
&lt;br /&gt;
Through manual testing, we aim to identify if all the features of the application are working as intended when the language conversion occurs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Scenario 1&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Log in to Expertiza as a student.&lt;br /&gt;
&lt;br /&gt;
2. Go to the “user profile” page and change “preferred language” to Hindi.&lt;br /&gt;
&lt;br /&gt;
3. Check to see if the English strings on the profile page are translated to Hindi.&lt;br /&gt;
&lt;br /&gt;
4. Check if a page for which Hindi translation keys are added has its English static strings translated to Hindi.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Scenario 2&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Log in to Expertiza as a student.&lt;br /&gt;
&lt;br /&gt;
2. Go to the “user profile” page and change “preferred language” to Nil.&lt;br /&gt;
&lt;br /&gt;
3.  Check to see if the English strings on the page are unchanged, as the “user profile” translates only if the student has a preference.&lt;br /&gt;
&lt;br /&gt;
4. Go to an assignment page for which Hindi translation keys are added, which is under a course with the default language set to Hindi, and check whether the English strings are translated to Hindi.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Scenario 3&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Log in to Expertiza as a student.&lt;br /&gt;
&lt;br /&gt;
2. Go to the “user profile” page and change “preferred language” to Nil.&lt;br /&gt;
&lt;br /&gt;
3.  Check to see if the English strings on the page are unchanged, as the “user profile” translates only if the student has a preference.&lt;br /&gt;
&lt;br /&gt;
4. Go to a non-course-specific page and verify that the page is displayed in English itself, as non of the default languages set for any of the courses should have any role.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Scenario 4&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Log in to Expertiza as a student.&lt;br /&gt;
&lt;br /&gt;
2. Go to the “user profile” page and change “preferred language” to Hindi.&lt;br /&gt;
&lt;br /&gt;
3.  Go to a page where translation keys aren’t added completely and make sure that the unspecified keys display strings in English as a fallback.&lt;br /&gt;
&lt;br /&gt;
== Future Scope==&lt;br /&gt;
'''1. Expand to more languages'''&amp;lt;br&amp;gt;&lt;br /&gt;
As part of this project we have targetted Hindi as a second language, however our work makes it easy to extend to other languages as well.&lt;br /&gt;
&lt;br /&gt;
'''2. Identify and implement the course language override on more course specific screens'''&amp;lt;br&amp;gt;&lt;br /&gt;
As part of this project, we have introduced a generic framework by which any view can provide a preferred language in which it should be rendered, this is required by this project for the course language feature set by the instructor.&lt;br /&gt;
We have currently made the assignment screen display in the course’s language, however other screens such as the “Your work” screen and so on are also specific to the course could also be rendered in the course language when the user has not provided a preference.&lt;br /&gt;
&lt;br /&gt;
== Team ==&lt;br /&gt;
&lt;br /&gt;
'''Team Members'''&lt;br /&gt;
&lt;br /&gt;
Reuben M. V. John [[mailto:rmjohn2@ncsu.edu rmjohn2@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Renji Joseph Sabu [[mailto:rsabu@ncsu.edu rsabu@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Ashwin Das [[mailto:adas9@ncsu.edu adas9@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Arnav Julka [[mailto:ajulka@ncsu.edu ajulka@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Mentor'''&lt;br /&gt;
&lt;br /&gt;
Jialin Cui [[mailto:jcui9@ncsu.edu jcui9@ncsu.edu]]&lt;/div&gt;</summary>
		<author><name>Ajulka</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization&amp;diff=140565</id>
		<title>CSC/ECE 517 Fall 2021 - E2159. Expertiza internationalization</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization&amp;diff=140565"/>
		<updated>2021-11-03T03:26:43Z</updated>

		<summary type="html">&lt;p&gt;Ajulka: /* Introduction - Purpose &amp;amp; Problem */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction - Purpose &amp;amp; Problem ==&lt;br /&gt;
&lt;br /&gt;
Currently, all Expertiza screens can only be viewed in English. Many Expertiza users are from other countries. This is a problem since this limits the accessibility of Expertiza. An important step in solving this problem is by making Expertiza available in more languages, which is a form of internationalization.&lt;br /&gt;
W3C defines [https://www.w3.org/International/questions/qa-i18n internationalization] as “''the design and development of a product, application or document content that enables easy localization for target audiences that vary in culture, region, or language.''”&lt;br /&gt;
&lt;br /&gt;
[[File:country_pie.png|none|500px|]]&amp;lt;br&amp;gt;&lt;br /&gt;
Survey of home country of Expertiza users for a given course&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Scope:''' The scope of this project is limited however only to static strings. i.e. user-generated content will not be automatically translated to other languages.&lt;br /&gt;
&lt;br /&gt;
'''Breaking down internationalization into 3 sequential subproblems:'''&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Twophase2.jpg|none|700px]]&amp;lt;br&amp;gt;&lt;br /&gt;
'''1. Language selection'''&lt;br /&gt;
@rsabu&lt;br /&gt;
&lt;br /&gt;
'''2. Rendering the language'''&amp;lt;br&amp;gt;&lt;br /&gt;
'''How do we go about rendering the screen in that language?''' &amp;lt;br&amp;gt;&lt;br /&gt;
In the previous step, we’ve identified the language in which a view is to be rendered. It is important to note that this language may not only differ for a different user, but also for a different page for the same user. The question now becomes, how do we render the screen in this language?&amp;lt;br&amp;gt;&lt;br /&gt;
To tackle this question, we explore 2 fundamental concepts:&amp;lt;br&amp;gt;&lt;br /&gt;
'''2.1 Views are composed of independent language elements'''&amp;lt;br&amp;gt;&lt;br /&gt;
While this is something we typically take for granted, it becomes especially important in the context of translation. That is, a view is not a single contiguous block of text, nor is it an atomic visualization of information (unlike a screenshot), but rather a carefully organized collection of individual elements such as texts, buttons, etc that each contain language that needs to be translated separately. Crucially, this means that we cannot swap out a page in one language in its entirety for a page in another language in its entirety. Instead, each individual element needs to be swapped out individually so as to only impact the language and not the structural composition of the page itself.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''2.2 Views require translation at a large number of call sites'''&amp;lt;br&amp;gt;&lt;br /&gt;
Given that a view is composed of individual elements, this also means that the computation of how to translate such an element such as a button’s text would need to be done separately for each element. This would result in not only a single centralized &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''3. Translation gaps'''&lt;br /&gt;
&lt;br /&gt;
== Scope ==&lt;br /&gt;
== Design ==&lt;br /&gt;
Proposed Solution&lt;br /&gt;
1. Language selection&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
'''''2. Rendering the language'''''&amp;lt;br&amp;gt;&lt;br /&gt;
Rendering the language&amp;lt;br&amp;gt;&lt;br /&gt;
Once we have determined the language in which to render the page, we now need to update the rails view code to actually generate the appropriate HTML in the target language. This is the responsibility of the view. However, currently, the actual content of the HTML is hardcoded in (red) English. For example:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;Summary Report for assignment: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;Team: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
As discussed earlier, “Views are composed of independent language elements” and so we cannot simply swap out the entire page content for a separate page in another language (Why? - See “swap out the entire view” in the alternative approaches section):&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;Rapport de synthèse pour l'affectation: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;Équipe: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;Instead, the better approach is to have a single unified view that dynamically changes based on the selected language:&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;&amp;lt;%=language==’en’ ? ‘Summary Report for assignment’ : ‘Rapport de synthèse pour l'affectation’&amp;gt;: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;&amp;lt;%=language==’en’ ? ‘Team’ : ‘Équipe’&amp;gt;: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;However this is clearly infeasible considering the number of call sites where we have to apply this logic. Thus, in order to maximize how concise the call site is, we can pull out this logic into a common helper function:&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;&amp;lt;%=localized(“report_summary.page_header”)&amp;gt;: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;&amp;lt;%=localized(“report_summary.team_label”)&amp;gt;: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;Here the assumption is that the localized(“key”) is aware of the currently selected language and that “report_summary.page_header” is the key for the header which is available in English and Hindi. The helper intelligently selects and returns the right text based on the currently selected language. Through this approach, we are able to render the view in multiple possible languages without any significant increase in the verbosity of the view.&lt;br /&gt;
&lt;br /&gt;
What’s more, is that the above problem is a common problem for user-facing applications and a standard library for doing the above and much more already exists for rails applications called i18n&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''''I18n - Internationalisation, How are we using I18n in Ruby on Rail'''''&amp;lt;br&amp;gt;&lt;br /&gt;
I18n is a ruby library/gem which helps us render the static string on the view dynamically. Dynamicity means that based on a local decision of choosing the current language of the view, the library returns the strings of that particular language at runtime.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
These strings, instead of hardcoding in the view.rb, are provided in external .yml files. Now at the View level, we can pass an id to the 't' function and the I18n library returns the string for that id of the current set language(called as locale). &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:i18n.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
For this purpose, we have to provide .yml files for each language and in those language-specific .yml, we have to provide a map of key-value pairs where the key is the id of the string and value is the string in that particular language. By default the language or locale is set to be English(:en). &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
THE GREATEST BENEFITS of using this library are - &amp;lt;br&amp;gt;&lt;br /&gt;
*The strings aren't hardcoded in the code/build. The strings are being fetched from external files which can be easily modified. For example, if one needs to change the text from 'Please Help' to 'Help', then one just needs to make a change in the .yml file and the change would reflect on the browser. For this change, we didn't need to redeploy the server. We just Decoupled the view when and where from what content is to be shown. &lt;br /&gt;
*Adding more languages is now super easy. Adding support for another language is just one line change in the config and adding a .yml file (having all the key-value pairs for the strings) for the new language. By doing this we can extend the language support as much as we want.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''''3. Translation gaps'''''&lt;br /&gt;
&amp;lt;br&amp;gt;Also, if the language is set to be Hindi or any other language but the key-value pair is not set for that particular string then, automatically the library returns the default which is the English text.&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;config.i18n.fallbacks = [:en]&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Alternate approaches ==&lt;br /&gt;
&lt;br /&gt;
'''1. Why not simply swap out the entire view for another language instead of each text?'''&amp;lt;br&amp;gt;&lt;br /&gt;
A view is an organized collection of multiple separate elements, views often involve dynamic generation and some level of sophistication. If we were to swap out one page in its entirety for another page this would often violate the '''DRY''' principle since we would have to have two separate implementations of the view in each language. Thus in the worst case, you have a complex view that has to be replicated dozens of times in various languages.&lt;br /&gt;
The majority of complexity of the page is not in the content itself but rather the code that executes to generate that content, thus it makes sense to instead maintain a single view and embed the language switching logic at each location where translation needs to occur to avoid replication of everything around it.&lt;br /&gt;
&lt;br /&gt;
'''2. Why did we pick i18n over implementing it ourselves?'''&amp;lt;br&amp;gt;&lt;br /&gt;
@ajulka&lt;br /&gt;
&lt;br /&gt;
'''3, Do we store the language preference, in the session or in the database?'''&amp;lt;br&amp;gt;&lt;br /&gt;
@rsabu&lt;br /&gt;
&lt;br /&gt;
== Use Case Diagram ==&lt;br /&gt;
== Major design patterns and principles used ==&lt;br /&gt;
&lt;br /&gt;
'''1. DRY: The i18n ‘t’ function'''&amp;lt;br&amp;gt;&lt;br /&gt;
We observe an extreme case of DRY with the t function of i18n.&lt;br /&gt;
For some background, the t function of the library takes in a key representing a text and returns the content referred to by that key in the preferred language of the user. It also performs many other functions such as falling back to a backup language if the translation for the preferred language has not been configured for that specific key. Thus since this logic has to be applied at every element of the view, it would behove us to extract this logic into a reusable function which is what the designers of the i18n library have employed&lt;br /&gt;
&lt;br /&gt;
'''2. Chain of responsibility'''&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Chainofresp.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The I18n library gives us an option to have many fall back options. When the required text for a given language is not found, we then move on to find the text for the next language in the chain and so on until we find it. And in the end we will put english as default language. So if the key value pair for the text is not found in none of the yml files then the text will be fetched from the English language yml file.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''3. Open closed principle &amp;amp; Strategy Pattern'''&amp;lt;br&amp;gt;&lt;br /&gt;
As discussed in the “Language selection&amp;quot; design proposal above, if the user has not selected a preferred language, we do not simply default the view to render in the application language (English). Instead, the project requirements state that for course specific screens such as the assignment view, we would need to render the view in the course’s language.&lt;br /&gt;
While we could implement this code into the application controller that checks the controller being access and accordingly applies overrides on the default language, this violates the open closed principle since we would need to extend this logic any time we introduce a new course specific screen. Instead a better approach is to delegate the decision of selecting the language to the view itself since the view would be most aware of whether the view is course specific or not. We can also preserve the DRYness through mix-ins.&lt;br /&gt;
&lt;br /&gt;
== Database Design ==&lt;br /&gt;
Database Modification ==&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
Test Details&lt;br /&gt;
Manual Testing&lt;br /&gt;
Scenario 1&lt;br /&gt;
Scenario 2&lt;br /&gt;
Scenario 3&lt;br /&gt;
Scenario 4&lt;br /&gt;
Scenario 5&lt;br /&gt;
== Future Scope==&lt;br /&gt;
'''1. Expand to more languages'''&amp;lt;br&amp;gt;&lt;br /&gt;
As part of this project we have targetted Hindi as a second language, however our work makes it easy to extend to other languages as well.&lt;br /&gt;
&lt;br /&gt;
'''2. Identify and implement the course language override on more course specific screens'''&amp;lt;br&amp;gt;&lt;br /&gt;
As part of this project, we have introduced a generic framework by which any view can provide a preferred language in which it should be rendered, this is required by this project for the course language feature set by the instructor.&lt;br /&gt;
We have currently made the assignment screen display in the course’s language, however other screens such as the “Your work” screen and so on are also specific to the course could also be rendered in the course language when the user has not provided a preference.&lt;br /&gt;
&lt;br /&gt;
== Team ==&lt;br /&gt;
&lt;br /&gt;
'''Team Members'''&lt;br /&gt;
&lt;br /&gt;
Reuben M. V. John [[mailto:rmjohn2@ncsu.edu rmjohn2@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Renji Joseph Sabu [[mailto:rsabu@ncsu.edu rsabu@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Ashwin Das [[mailto:adas9@ncsu.edu adas9@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Arnav Julka [[mailto:ajulka@ncsu.edu ajulka@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Mentor'''&lt;br /&gt;
&lt;br /&gt;
Jialin Cui [[mailto:jcui9@ncsu.edu jcui9@ncsu.edu]]&lt;/div&gt;</summary>
		<author><name>Ajulka</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization&amp;diff=140564</id>
		<title>CSC/ECE 517 Fall 2021 - E2159. Expertiza internationalization</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization&amp;diff=140564"/>
		<updated>2021-11-03T03:26:28Z</updated>

		<summary type="html">&lt;p&gt;Ajulka: /* Introduction - Purpose &amp;amp; Problem */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction - Purpose &amp;amp; Problem ==&lt;br /&gt;
&lt;br /&gt;
Currently, all Expertiza screens can only be viewed in English. Many Expertiza users are from other countries. This is a problem since this limits the accessibility of Expertiza. An important step in solving this problem is by making Expertiza available in more languages, which is a form of internationalization.&lt;br /&gt;
W3C defines [https://www.w3.org/International/questions/qa-i18n internationalization] as “''the design and development of a product, application or document content that enables easy localization for target audiences that vary in culture, region, or language.''”&lt;br /&gt;
&lt;br /&gt;
[[File:country_pie.png|none|500px|]]&amp;lt;br&amp;gt;&lt;br /&gt;
Survey of home country of Expertiza users for a given course&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Scope:''' The scope of this project is limited however only to static strings. i.e. user-generated content will not be automatically translated to other languages.&lt;br /&gt;
&lt;br /&gt;
'''Breaking down internationalization into 3 sequential subproblems:'''&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Twophase2.jpg|none|500px]]&amp;lt;br&amp;gt;&lt;br /&gt;
'''1. Language selection'''&lt;br /&gt;
@rsabu&lt;br /&gt;
&lt;br /&gt;
'''2. Rendering the language'''&amp;lt;br&amp;gt;&lt;br /&gt;
'''How do we go about rendering the screen in that language?''' &amp;lt;br&amp;gt;&lt;br /&gt;
In the previous step, we’ve identified the language in which a view is to be rendered. It is important to note that this language may not only differ for a different user, but also for a different page for the same user. The question now becomes, how do we render the screen in this language?&amp;lt;br&amp;gt;&lt;br /&gt;
To tackle this question, we explore 2 fundamental concepts:&amp;lt;br&amp;gt;&lt;br /&gt;
'''2.1 Views are composed of independent language elements'''&amp;lt;br&amp;gt;&lt;br /&gt;
While this is something we typically take for granted, it becomes especially important in the context of translation. That is, a view is not a single contiguous block of text, nor is it an atomic visualization of information (unlike a screenshot), but rather a carefully organized collection of individual elements such as texts, buttons, etc that each contain language that needs to be translated separately. Crucially, this means that we cannot swap out a page in one language in its entirety for a page in another language in its entirety. Instead, each individual element needs to be swapped out individually so as to only impact the language and not the structural composition of the page itself.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''2.2 Views require translation at a large number of call sites'''&amp;lt;br&amp;gt;&lt;br /&gt;
Given that a view is composed of individual elements, this also means that the computation of how to translate such an element such as a button’s text would need to be done separately for each element. This would result in not only a single centralized &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''3. Translation gaps'''&lt;br /&gt;
&lt;br /&gt;
== Scope ==&lt;br /&gt;
== Design ==&lt;br /&gt;
Proposed Solution&lt;br /&gt;
1. Language selection&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
'''''2. Rendering the language'''''&amp;lt;br&amp;gt;&lt;br /&gt;
Rendering the language&amp;lt;br&amp;gt;&lt;br /&gt;
Once we have determined the language in which to render the page, we now need to update the rails view code to actually generate the appropriate HTML in the target language. This is the responsibility of the view. However, currently, the actual content of the HTML is hardcoded in (red) English. For example:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;Summary Report for assignment: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;Team: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
As discussed earlier, “Views are composed of independent language elements” and so we cannot simply swap out the entire page content for a separate page in another language (Why? - See “swap out the entire view” in the alternative approaches section):&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;Rapport de synthèse pour l'affectation: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;Équipe: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;Instead, the better approach is to have a single unified view that dynamically changes based on the selected language:&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;&amp;lt;%=language==’en’ ? ‘Summary Report for assignment’ : ‘Rapport de synthèse pour l'affectation’&amp;gt;: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;&amp;lt;%=language==’en’ ? ‘Team’ : ‘Équipe’&amp;gt;: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;However this is clearly infeasible considering the number of call sites where we have to apply this logic. Thus, in order to maximize how concise the call site is, we can pull out this logic into a common helper function:&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;&amp;lt;%=localized(“report_summary.page_header”)&amp;gt;: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;&amp;lt;%=localized(“report_summary.team_label”)&amp;gt;: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;Here the assumption is that the localized(“key”) is aware of the currently selected language and that “report_summary.page_header” is the key for the header which is available in English and Hindi. The helper intelligently selects and returns the right text based on the currently selected language. Through this approach, we are able to render the view in multiple possible languages without any significant increase in the verbosity of the view.&lt;br /&gt;
&lt;br /&gt;
What’s more, is that the above problem is a common problem for user-facing applications and a standard library for doing the above and much more already exists for rails applications called i18n&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''''I18n - Internationalisation, How are we using I18n in Ruby on Rail'''''&amp;lt;br&amp;gt;&lt;br /&gt;
I18n is a ruby library/gem which helps us render the static string on the view dynamically. Dynamicity means that based on a local decision of choosing the current language of the view, the library returns the strings of that particular language at runtime.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
These strings, instead of hardcoding in the view.rb, are provided in external .yml files. Now at the View level, we can pass an id to the 't' function and the I18n library returns the string for that id of the current set language(called as locale). &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:i18n.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
For this purpose, we have to provide .yml files for each language and in those language-specific .yml, we have to provide a map of key-value pairs where the key is the id of the string and value is the string in that particular language. By default the language or locale is set to be English(:en). &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
THE GREATEST BENEFITS of using this library are - &amp;lt;br&amp;gt;&lt;br /&gt;
*The strings aren't hardcoded in the code/build. The strings are being fetched from external files which can be easily modified. For example, if one needs to change the text from 'Please Help' to 'Help', then one just needs to make a change in the .yml file and the change would reflect on the browser. For this change, we didn't need to redeploy the server. We just Decoupled the view when and where from what content is to be shown. &lt;br /&gt;
*Adding more languages is now super easy. Adding support for another language is just one line change in the config and adding a .yml file (having all the key-value pairs for the strings) for the new language. By doing this we can extend the language support as much as we want.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''''3. Translation gaps'''''&lt;br /&gt;
&amp;lt;br&amp;gt;Also, if the language is set to be Hindi or any other language but the key-value pair is not set for that particular string then, automatically the library returns the default which is the English text.&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;config.i18n.fallbacks = [:en]&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Alternate approaches ==&lt;br /&gt;
&lt;br /&gt;
'''1. Why not simply swap out the entire view for another language instead of each text?'''&amp;lt;br&amp;gt;&lt;br /&gt;
A view is an organized collection of multiple separate elements, views often involve dynamic generation and some level of sophistication. If we were to swap out one page in its entirety for another page this would often violate the '''DRY''' principle since we would have to have two separate implementations of the view in each language. Thus in the worst case, you have a complex view that has to be replicated dozens of times in various languages.&lt;br /&gt;
The majority of complexity of the page is not in the content itself but rather the code that executes to generate that content, thus it makes sense to instead maintain a single view and embed the language switching logic at each location where translation needs to occur to avoid replication of everything around it.&lt;br /&gt;
&lt;br /&gt;
'''2. Why did we pick i18n over implementing it ourselves?'''&amp;lt;br&amp;gt;&lt;br /&gt;
@ajulka&lt;br /&gt;
&lt;br /&gt;
'''3, Do we store the language preference, in the session or in the database?'''&amp;lt;br&amp;gt;&lt;br /&gt;
@rsabu&lt;br /&gt;
&lt;br /&gt;
== Use Case Diagram ==&lt;br /&gt;
== Major design patterns and principles used ==&lt;br /&gt;
&lt;br /&gt;
'''1. DRY: The i18n ‘t’ function'''&amp;lt;br&amp;gt;&lt;br /&gt;
We observe an extreme case of DRY with the t function of i18n.&lt;br /&gt;
For some background, the t function of the library takes in a key representing a text and returns the content referred to by that key in the preferred language of the user. It also performs many other functions such as falling back to a backup language if the translation for the preferred language has not been configured for that specific key. Thus since this logic has to be applied at every element of the view, it would behove us to extract this logic into a reusable function which is what the designers of the i18n library have employed&lt;br /&gt;
&lt;br /&gt;
'''2. Chain of responsibility'''&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Chainofresp.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The I18n library gives us an option to have many fall back options. When the required text for a given language is not found, we then move on to find the text for the next language in the chain and so on until we find it. And in the end we will put english as default language. So if the key value pair for the text is not found in none of the yml files then the text will be fetched from the English language yml file.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''3. Open closed principle &amp;amp; Strategy Pattern'''&amp;lt;br&amp;gt;&lt;br /&gt;
As discussed in the “Language selection&amp;quot; design proposal above, if the user has not selected a preferred language, we do not simply default the view to render in the application language (English). Instead, the project requirements state that for course specific screens such as the assignment view, we would need to render the view in the course’s language.&lt;br /&gt;
While we could implement this code into the application controller that checks the controller being access and accordingly applies overrides on the default language, this violates the open closed principle since we would need to extend this logic any time we introduce a new course specific screen. Instead a better approach is to delegate the decision of selecting the language to the view itself since the view would be most aware of whether the view is course specific or not. We can also preserve the DRYness through mix-ins.&lt;br /&gt;
&lt;br /&gt;
== Database Design ==&lt;br /&gt;
Database Modification ==&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
Test Details&lt;br /&gt;
Manual Testing&lt;br /&gt;
Scenario 1&lt;br /&gt;
Scenario 2&lt;br /&gt;
Scenario 3&lt;br /&gt;
Scenario 4&lt;br /&gt;
Scenario 5&lt;br /&gt;
== Future Scope==&lt;br /&gt;
'''1. Expand to more languages'''&amp;lt;br&amp;gt;&lt;br /&gt;
As part of this project we have targetted Hindi as a second language, however our work makes it easy to extend to other languages as well.&lt;br /&gt;
&lt;br /&gt;
'''2. Identify and implement the course language override on more course specific screens'''&amp;lt;br&amp;gt;&lt;br /&gt;
As part of this project, we have introduced a generic framework by which any view can provide a preferred language in which it should be rendered, this is required by this project for the course language feature set by the instructor.&lt;br /&gt;
We have currently made the assignment screen display in the course’s language, however other screens such as the “Your work” screen and so on are also specific to the course could also be rendered in the course language when the user has not provided a preference.&lt;br /&gt;
&lt;br /&gt;
== Team ==&lt;br /&gt;
&lt;br /&gt;
'''Team Members'''&lt;br /&gt;
&lt;br /&gt;
Reuben M. V. John [[mailto:rmjohn2@ncsu.edu rmjohn2@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Renji Joseph Sabu [[mailto:rsabu@ncsu.edu rsabu@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Ashwin Das [[mailto:adas9@ncsu.edu adas9@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Arnav Julka [[mailto:ajulka@ncsu.edu ajulka@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Mentor'''&lt;br /&gt;
&lt;br /&gt;
Jialin Cui [[mailto:jcui9@ncsu.edu jcui9@ncsu.edu]]&lt;/div&gt;</summary>
		<author><name>Ajulka</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization&amp;diff=140539</id>
		<title>CSC/ECE 517 Fall 2021 - E2159. Expertiza internationalization</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization&amp;diff=140539"/>
		<updated>2021-11-03T01:49:49Z</updated>

		<summary type="html">&lt;p&gt;Ajulka: /* Introduction - Purpose &amp;amp; Problem */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction - Purpose &amp;amp; Problem ==&lt;br /&gt;
&lt;br /&gt;
Currently, all Expertiza screens can only be viewed in English. Many Expertiza users are from other countries. This is a problem since this limits the accessibility of Expertiza. An important step in solving this problem is by making Expertiza available in more languages, which is a form of internationalization.&lt;br /&gt;
W3C defines [https://www.w3.org/International/questions/qa-i18n internationalization] as “''the design and development of a product, application or document content that enables easy localization for target audiences that vary in culture, region, or language.''”&lt;br /&gt;
&lt;br /&gt;
[[File:country_pie.png|none|500px|]]&amp;lt;br&amp;gt;&lt;br /&gt;
Survey of home country of Expertiza users for a given course&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Scope:''' The scope of this project is limited however only to static strings. i.e. user-generated content will not be automatically translated to other languages.&lt;br /&gt;
&lt;br /&gt;
'''Breaking down internationalization into 3 sequential subproblems:'''&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Twophase2.jpg]]&amp;lt;br&amp;gt;&lt;br /&gt;
'''1. Language selection'''&lt;br /&gt;
@rsabu&lt;br /&gt;
&lt;br /&gt;
'''2. Rendering the language'''&amp;lt;br&amp;gt;&lt;br /&gt;
'''How do we go about rendering the screen in that language?''' &amp;lt;br&amp;gt;&lt;br /&gt;
In the previous step, we’ve identified the language in which a view is to be rendered. It is important to note that this language may not only differ for a different user, but also for a different page for the same user. The question now becomes, how do we render the screen in this language?&amp;lt;br&amp;gt;&lt;br /&gt;
To tackle this question, we explore 2 fundamental concepts:&amp;lt;br&amp;gt;&lt;br /&gt;
'''2.1 Views are composed of independent language elements'''&amp;lt;br&amp;gt;&lt;br /&gt;
While this is something we typically take for granted, it becomes especially important in the context of translation. That is, a view is not a single contiguous block of text, nor is it an atomic visualization of information (unlike a screenshot), but rather a carefully organized collection of individual elements such as texts, buttons, etc that each contain language that needs to be translated separately. Crucially, this means that we cannot swap out a page in one language in its entirety for a page in another language in its entirety. Instead, each individual element needs to be swapped out individually so as to only impact the language and not the structural composition of the page itself.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''2.2 Views require translation at a large number of call sites'''&amp;lt;br&amp;gt;&lt;br /&gt;
Given that a view is composed of individual elements, this also means that the computation of how to translate such an element such as a button’s text would need to be done separately for each element. This would result in not only a single centralized &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''3. Translation gaps'''&lt;br /&gt;
&lt;br /&gt;
== Scope ==&lt;br /&gt;
== Design ==&lt;br /&gt;
Proposed Solution&lt;br /&gt;
1. Language selection&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
'''''2. Rendering the language'''''&amp;lt;br&amp;gt;&lt;br /&gt;
Rendering the language&amp;lt;br&amp;gt;&lt;br /&gt;
Once we have determined the language in which to render the page, we now need to update the rails view code to actually generate the appropriate HTML in the target language. This is the responsibility of the view. However, currently, the actual content of the HTML is hardcoded in (red) English. For example:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;Summary Report for assignment: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;Team: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
As discussed earlier, “Views are composed of independent language elements” and so we cannot simply swap out the entire page content for a separate page in another language (Why? - See “swap out the entire view” in the alternative approaches section):&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;Rapport de synthèse pour l'affectation: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;Équipe: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;Instead, the better approach is to have a single unified view that dynamically changes based on the selected language:&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;&amp;lt;%=language==’en’ ? ‘Summary Report for assignment’ : ‘Rapport de synthèse pour l'affectation’&amp;gt;: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;&amp;lt;%=language==’en’ ? ‘Team’ : ‘Équipe’&amp;gt;: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;However this is clearly infeasible considering the number of call sites where we have to apply this logic. Thus, in order to maximize how concise the call site is, we can pull out this logic into a common helper function:&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;&amp;lt;%=localized(“report_summary.page_header”)&amp;gt;: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;&amp;lt;%=localized(“report_summary.team_label”)&amp;gt;: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;Here the assumption is that the localized(“key”) is aware of the currently selected language and that “report_summary.page_header” is the key for the header which is available in English and Hindi. The helper intelligently selects and returns the right text based on the currently selected language. Through this approach, we are able to render the view in multiple possible languages without any significant increase in the verbosity of the view.&lt;br /&gt;
&lt;br /&gt;
What’s more, is that the above problem is a common problem for user-facing applications and a standard library for doing the above and much more already exists for rails applications called i18n&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''''I18n - Internationalisation, How are we using I18n in Ruby on Rail'''''&amp;lt;br&amp;gt;&lt;br /&gt;
I18n is a ruby library/gem which helps us render the static string on the view dynamically. Dynamicity means that based on a local decision of choosing the current language of the view, the library returns the strings of that particular language at runtime.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
These strings, instead of hardcoding in the view.rb, are provided in external .yml files. Now at the View level, we can pass an id to the 't' function and the I18n library returns the string for that id of the current set language(called as locale). &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:i18n.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
For this purpose, we have to provide .yml files for each language and in those language-specific .yml, we have to provide a map of key-value pairs where the key is the id of the string and value is the string in that particular language. By default the language or locale is set to be English(:en). &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
THE GREATEST BENEFITS of using this library are - &amp;lt;br&amp;gt;&lt;br /&gt;
*The strings aren't hardcoded in the code/build. The strings are being fetched from external files which can be easily modified. For example, if one needs to change the text from 'Please Help' to 'Help', then one just needs to make a change in the .yml file and the change would reflect on the browser. For this change, we didn't need to redeploy the server. We just Decoupled the view when and where from what content is to be shown. &lt;br /&gt;
*Adding more languages is now super easy. Adding support for another language is just one line change in the config and adding a .yml file (having all the key-value pairs for the strings) for the new language. By doing this we can extend the language support as much as we want.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''''3. Translation gaps'''''&lt;br /&gt;
&amp;lt;br&amp;gt;Also, if the language is set to be Hindi or any other language but the key-value pair is not set for that particular string then, automatically the library returns the default which is the English text.&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;config.i18n.fallbacks = [:en]&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Alternate approaches ==&lt;br /&gt;
&lt;br /&gt;
'''1. Why not simply swap out the entire view for another language instead of each text?'''&amp;lt;br&amp;gt;&lt;br /&gt;
A view is an organized collection of multiple separate elements, views often involve dynamic generation and some level of sophistication. If we were to swap out one page in its entirety for another page this would often violate the '''DRY''' principle since we would have to have two separate implementations of the view in each language. Thus in the worst case, you have a complex view that has to be replicated dozens of times in various languages.&lt;br /&gt;
The majority of complexity of the page is not in the content itself but rather the code that executes to generate that content, thus it makes sense to instead maintain a single view and embed the language switching logic at each location where translation needs to occur to avoid replication of everything around it.&lt;br /&gt;
&lt;br /&gt;
'''2. Why did we pick i18n over implementing it ourselves?'''&amp;lt;br&amp;gt;&lt;br /&gt;
@ajulka&lt;br /&gt;
&lt;br /&gt;
'''3, Do we store the language preference, in the session or in the database?'''&amp;lt;br&amp;gt;&lt;br /&gt;
@rsabu&lt;br /&gt;
&lt;br /&gt;
== Use Case Diagram ==&lt;br /&gt;
== Major design patterns and principles used ==&lt;br /&gt;
&lt;br /&gt;
'''1. DRY: The i18n ‘t’ function'''&amp;lt;br&amp;gt;&lt;br /&gt;
We observe an extreme case of DRY with the t function of i18n.&lt;br /&gt;
For some background, the t function of the library takes in a key representing a text and returns the content referred to by that key in the preferred language of the user. It also performs many other functions such as falling back to a backup language if the translation for the preferred language has not been configured for that specific key. Thus since this logic has to be applied at every element of the view, it would behove us to extract this logic into a reusable function which is what the designers of the i18n library have employed&lt;br /&gt;
&lt;br /&gt;
'''2. Chain of responsibility'''&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Chainofresp.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The I18n library gives us an option to have many fall back options. When the required text for a given language is not found, we then move on to find the text for the next language in the chain and so on until we find it. And in the end we will put english as default language. So if the key value pair for the text is not found in none of the yml files then the text will be fetched from the English language yml file.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''3. Open closed principle &amp;amp; Strategy Pattern'''&amp;lt;br&amp;gt;&lt;br /&gt;
As discussed in the “Language selection&amp;quot; design proposal above, if the user has not selected a preferred language, we do not simply default the view to render in the application language (English). Instead, the project requirements state that for course specific screens such as the assignment view, we would need to render the view in the course’s language.&lt;br /&gt;
While we could implement this code into the application controller that checks the controller being access and accordingly applies overrides on the default language, this violates the open closed principle since we would need to extend this logic any time we introduce a new course specific screen. Instead a better approach is to delegate the decision of selecting the language to the view itself since the view would be most aware of whether the view is course specific or not. We can also preserve the DRYness through mix-ins.&lt;br /&gt;
&lt;br /&gt;
== Database Design ==&lt;br /&gt;
Database Modification ==&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
Test Details&lt;br /&gt;
Manual Testing&lt;br /&gt;
Scenario 1&lt;br /&gt;
Scenario 2&lt;br /&gt;
Scenario 3&lt;br /&gt;
Scenario 4&lt;br /&gt;
Scenario 5&lt;br /&gt;
== Future Scope==&lt;br /&gt;
'''1. Expand to more languages'''&amp;lt;br&amp;gt;&lt;br /&gt;
As part of this project we have targetted Hindi as a second language, however our work makes it easy to extend to other languages as well.&lt;br /&gt;
&lt;br /&gt;
'''2. Identify and implement the course language override on more course specific screens'''&amp;lt;br&amp;gt;&lt;br /&gt;
As part of this project, we have introduced a generic framework by which any view can provide a preferred language in which it should be rendered, this is required by this project for the course language feature set by the instructor.&lt;br /&gt;
We have currently made the assignment screen display in the course’s language, however other screens such as the “Your work” screen and so on are also specific to the course could also be rendered in the course language when the user has not provided a preference.&lt;br /&gt;
&lt;br /&gt;
== Team ==&lt;br /&gt;
&lt;br /&gt;
'''Team Members'''&lt;br /&gt;
&lt;br /&gt;
Reuben M. V. John [[mailto:rmjohn2@ncsu.edu rmjohn2@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Renji Joseph Sabu [[mailto:rsabu@ncsu.edu rsabu@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Ashwin Das [[mailto:adas9@ncsu.edu adas9@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Arnav Julka [[mailto:ajulka@ncsu.edu ajulka@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Mentor'''&lt;br /&gt;
&lt;br /&gt;
Jialin Cui [[mailto:jcui9@ncsu.edu jcui9@ncsu.edu]]&lt;/div&gt;</summary>
		<author><name>Ajulka</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization&amp;diff=140538</id>
		<title>CSC/ECE 517 Fall 2021 - E2159. Expertiza internationalization</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization&amp;diff=140538"/>
		<updated>2021-11-03T01:49:32Z</updated>

		<summary type="html">&lt;p&gt;Ajulka: /* Introduction - Purpose &amp;amp; Problem */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction - Purpose &amp;amp; Problem ==&lt;br /&gt;
&lt;br /&gt;
Currently, all Expertiza screens can only be viewed in English. Many Expertiza users are from other countries. This is a problem since this limits the accessibility of Expertiza. An important step in solving this problem is by making Expertiza available in more languages, which is a form of internationalization.&lt;br /&gt;
W3C defines [https://www.w3.org/International/questions/qa-i18n internationalization] as “''the design and development of a product, application or document content that enables easy localization for target audiences that vary in culture, region, or language.''”&lt;br /&gt;
&lt;br /&gt;
[[File:country_pie.png|none|500px|]]&amp;lt;br&amp;gt;&lt;br /&gt;
Survey of home country of Expertiza users for a given course&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Scope:''' The scope of this project is limited however only to static strings. i.e. user-generated content will not be automatically translated to other languages.&lt;br /&gt;
&lt;br /&gt;
'''Breaking down internationalization into 3 sequential subproblems:'''&lt;br /&gt;
[[File:Twophase2.jpg]]&lt;br /&gt;
'''1. Language selection'''&lt;br /&gt;
@rsabu&lt;br /&gt;
&lt;br /&gt;
'''2. Rendering the language'''&amp;lt;br&amp;gt;&lt;br /&gt;
'''How do we go about rendering the screen in that language?''' &amp;lt;br&amp;gt;&lt;br /&gt;
In the previous step, we’ve identified the language in which a view is to be rendered. It is important to note that this language may not only differ for a different user, but also for a different page for the same user. The question now becomes, how do we render the screen in this language?&amp;lt;br&amp;gt;&lt;br /&gt;
To tackle this question, we explore 2 fundamental concepts:&amp;lt;br&amp;gt;&lt;br /&gt;
'''2.1 Views are composed of independent language elements'''&amp;lt;br&amp;gt;&lt;br /&gt;
While this is something we typically take for granted, it becomes especially important in the context of translation. That is, a view is not a single contiguous block of text, nor is it an atomic visualization of information (unlike a screenshot), but rather a carefully organized collection of individual elements such as texts, buttons, etc that each contain language that needs to be translated separately. Crucially, this means that we cannot swap out a page in one language in its entirety for a page in another language in its entirety. Instead, each individual element needs to be swapped out individually so as to only impact the language and not the structural composition of the page itself.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''2.2 Views require translation at a large number of call sites'''&amp;lt;br&amp;gt;&lt;br /&gt;
Given that a view is composed of individual elements, this also means that the computation of how to translate such an element such as a button’s text would need to be done separately for each element. This would result in not only a single centralized &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''3. Translation gaps'''&lt;br /&gt;
&lt;br /&gt;
== Scope ==&lt;br /&gt;
== Design ==&lt;br /&gt;
Proposed Solution&lt;br /&gt;
1. Language selection&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
'''''2. Rendering the language'''''&amp;lt;br&amp;gt;&lt;br /&gt;
Rendering the language&amp;lt;br&amp;gt;&lt;br /&gt;
Once we have determined the language in which to render the page, we now need to update the rails view code to actually generate the appropriate HTML in the target language. This is the responsibility of the view. However, currently, the actual content of the HTML is hardcoded in (red) English. For example:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;Summary Report for assignment: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;Team: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
As discussed earlier, “Views are composed of independent language elements” and so we cannot simply swap out the entire page content for a separate page in another language (Why? - See “swap out the entire view” in the alternative approaches section):&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;Rapport de synthèse pour l'affectation: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;Équipe: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;Instead, the better approach is to have a single unified view that dynamically changes based on the selected language:&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;&amp;lt;%=language==’en’ ? ‘Summary Report for assignment’ : ‘Rapport de synthèse pour l'affectation’&amp;gt;: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;&amp;lt;%=language==’en’ ? ‘Team’ : ‘Équipe’&amp;gt;: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;However this is clearly infeasible considering the number of call sites where we have to apply this logic. Thus, in order to maximize how concise the call site is, we can pull out this logic into a common helper function:&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;&amp;lt;%=localized(“report_summary.page_header”)&amp;gt;: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;&amp;lt;%=localized(“report_summary.team_label”)&amp;gt;: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;Here the assumption is that the localized(“key”) is aware of the currently selected language and that “report_summary.page_header” is the key for the header which is available in English and Hindi. The helper intelligently selects and returns the right text based on the currently selected language. Through this approach, we are able to render the view in multiple possible languages without any significant increase in the verbosity of the view.&lt;br /&gt;
&lt;br /&gt;
What’s more, is that the above problem is a common problem for user-facing applications and a standard library for doing the above and much more already exists for rails applications called i18n&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''''I18n - Internationalisation, How are we using I18n in Ruby on Rail'''''&amp;lt;br&amp;gt;&lt;br /&gt;
I18n is a ruby library/gem which helps us render the static string on the view dynamically. Dynamicity means that based on a local decision of choosing the current language of the view, the library returns the strings of that particular language at runtime.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
These strings, instead of hardcoding in the view.rb, are provided in external .yml files. Now at the View level, we can pass an id to the 't' function and the I18n library returns the string for that id of the current set language(called as locale). &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:i18n.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
For this purpose, we have to provide .yml files for each language and in those language-specific .yml, we have to provide a map of key-value pairs where the key is the id of the string and value is the string in that particular language. By default the language or locale is set to be English(:en). &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
THE GREATEST BENEFITS of using this library are - &amp;lt;br&amp;gt;&lt;br /&gt;
*The strings aren't hardcoded in the code/build. The strings are being fetched from external files which can be easily modified. For example, if one needs to change the text from 'Please Help' to 'Help', then one just needs to make a change in the .yml file and the change would reflect on the browser. For this change, we didn't need to redeploy the server. We just Decoupled the view when and where from what content is to be shown. &lt;br /&gt;
*Adding more languages is now super easy. Adding support for another language is just one line change in the config and adding a .yml file (having all the key-value pairs for the strings) for the new language. By doing this we can extend the language support as much as we want.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''''3. Translation gaps'''''&lt;br /&gt;
&amp;lt;br&amp;gt;Also, if the language is set to be Hindi or any other language but the key-value pair is not set for that particular string then, automatically the library returns the default which is the English text.&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;config.i18n.fallbacks = [:en]&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Alternate approaches ==&lt;br /&gt;
&lt;br /&gt;
'''1. Why not simply swap out the entire view for another language instead of each text?'''&amp;lt;br&amp;gt;&lt;br /&gt;
A view is an organized collection of multiple separate elements, views often involve dynamic generation and some level of sophistication. If we were to swap out one page in its entirety for another page this would often violate the '''DRY''' principle since we would have to have two separate implementations of the view in each language. Thus in the worst case, you have a complex view that has to be replicated dozens of times in various languages.&lt;br /&gt;
The majority of complexity of the page is not in the content itself but rather the code that executes to generate that content, thus it makes sense to instead maintain a single view and embed the language switching logic at each location where translation needs to occur to avoid replication of everything around it.&lt;br /&gt;
&lt;br /&gt;
'''2. Why did we pick i18n over implementing it ourselves?'''&amp;lt;br&amp;gt;&lt;br /&gt;
@ajulka&lt;br /&gt;
&lt;br /&gt;
'''3, Do we store the language preference, in the session or in the database?'''&amp;lt;br&amp;gt;&lt;br /&gt;
@rsabu&lt;br /&gt;
&lt;br /&gt;
== Use Case Diagram ==&lt;br /&gt;
== Major design patterns and principles used ==&lt;br /&gt;
&lt;br /&gt;
'''1. DRY: The i18n ‘t’ function'''&amp;lt;br&amp;gt;&lt;br /&gt;
We observe an extreme case of DRY with the t function of i18n.&lt;br /&gt;
For some background, the t function of the library takes in a key representing a text and returns the content referred to by that key in the preferred language of the user. It also performs many other functions such as falling back to a backup language if the translation for the preferred language has not been configured for that specific key. Thus since this logic has to be applied at every element of the view, it would behove us to extract this logic into a reusable function which is what the designers of the i18n library have employed&lt;br /&gt;
&lt;br /&gt;
'''2. Chain of responsibility'''&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Chainofresp.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The I18n library gives us an option to have many fall back options. When the required text for a given language is not found, we then move on to find the text for the next language in the chain and so on until we find it. And in the end we will put english as default language. So if the key value pair for the text is not found in none of the yml files then the text will be fetched from the English language yml file.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''3. Open closed principle &amp;amp; Strategy Pattern'''&amp;lt;br&amp;gt;&lt;br /&gt;
As discussed in the “Language selection&amp;quot; design proposal above, if the user has not selected a preferred language, we do not simply default the view to render in the application language (English). Instead, the project requirements state that for course specific screens such as the assignment view, we would need to render the view in the course’s language.&lt;br /&gt;
While we could implement this code into the application controller that checks the controller being access and accordingly applies overrides on the default language, this violates the open closed principle since we would need to extend this logic any time we introduce a new course specific screen. Instead a better approach is to delegate the decision of selecting the language to the view itself since the view would be most aware of whether the view is course specific or not. We can also preserve the DRYness through mix-ins.&lt;br /&gt;
&lt;br /&gt;
== Database Design ==&lt;br /&gt;
Database Modification ==&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
Test Details&lt;br /&gt;
Manual Testing&lt;br /&gt;
Scenario 1&lt;br /&gt;
Scenario 2&lt;br /&gt;
Scenario 3&lt;br /&gt;
Scenario 4&lt;br /&gt;
Scenario 5&lt;br /&gt;
== Future Scope==&lt;br /&gt;
'''1. Expand to more languages'''&amp;lt;br&amp;gt;&lt;br /&gt;
As part of this project we have targetted Hindi as a second language, however our work makes it easy to extend to other languages as well.&lt;br /&gt;
&lt;br /&gt;
'''2. Identify and implement the course language override on more course specific screens'''&amp;lt;br&amp;gt;&lt;br /&gt;
As part of this project, we have introduced a generic framework by which any view can provide a preferred language in which it should be rendered, this is required by this project for the course language feature set by the instructor.&lt;br /&gt;
We have currently made the assignment screen display in the course’s language, however other screens such as the “Your work” screen and so on are also specific to the course could also be rendered in the course language when the user has not provided a preference.&lt;br /&gt;
&lt;br /&gt;
== Team ==&lt;br /&gt;
&lt;br /&gt;
'''Team Members'''&lt;br /&gt;
&lt;br /&gt;
Reuben M. V. John [[mailto:rmjohn2@ncsu.edu rmjohn2@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Renji Joseph Sabu [[mailto:rsabu@ncsu.edu rsabu@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Ashwin Das [[mailto:adas9@ncsu.edu adas9@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Arnav Julka [[mailto:ajulka@ncsu.edu ajulka@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Mentor'''&lt;br /&gt;
&lt;br /&gt;
Jialin Cui [[mailto:jcui9@ncsu.edu jcui9@ncsu.edu]]&lt;/div&gt;</summary>
		<author><name>Ajulka</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization&amp;diff=140537</id>
		<title>CSC/ECE 517 Fall 2021 - E2159. Expertiza internationalization</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization&amp;diff=140537"/>
		<updated>2021-11-03T01:49:17Z</updated>

		<summary type="html">&lt;p&gt;Ajulka: /* Introduction - Purpose &amp;amp; Problem */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction - Purpose &amp;amp; Problem ==&lt;br /&gt;
&lt;br /&gt;
Currently, all Expertiza screens can only be viewed in English. Many Expertiza users are from other countries. This is a problem since this limits the accessibility of Expertiza. An important step in solving this problem is by making Expertiza available in more languages, which is a form of internationalization.&lt;br /&gt;
W3C defines [https://www.w3.org/International/questions/qa-i18n internationalization] as “''the design and development of a product, application or document content that enables easy localization for target audiences that vary in culture, region, or language.''”&lt;br /&gt;
&lt;br /&gt;
[[File:country_pie.png|none|500px|]]&amp;lt;br&amp;gt;&lt;br /&gt;
Survey of home country of Expertiza users for a given course&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Scope:''' The scope of this project is limited however only to static strings. i.e. user-generated content will not be automatically translated to other languages.&lt;br /&gt;
&lt;br /&gt;
'''Breaking down internationalization into 3 sequential subproblems:'''&lt;br /&gt;
[[File:File:Twophase2.jpg]]&lt;br /&gt;
'''1. Language selection'''&lt;br /&gt;
@rsabu&lt;br /&gt;
&lt;br /&gt;
'''2. Rendering the language'''&amp;lt;br&amp;gt;&lt;br /&gt;
'''How do we go about rendering the screen in that language?''' &amp;lt;br&amp;gt;&lt;br /&gt;
In the previous step, we’ve identified the language in which a view is to be rendered. It is important to note that this language may not only differ for a different user, but also for a different page for the same user. The question now becomes, how do we render the screen in this language?&amp;lt;br&amp;gt;&lt;br /&gt;
To tackle this question, we explore 2 fundamental concepts:&amp;lt;br&amp;gt;&lt;br /&gt;
'''2.1 Views are composed of independent language elements'''&amp;lt;br&amp;gt;&lt;br /&gt;
While this is something we typically take for granted, it becomes especially important in the context of translation. That is, a view is not a single contiguous block of text, nor is it an atomic visualization of information (unlike a screenshot), but rather a carefully organized collection of individual elements such as texts, buttons, etc that each contain language that needs to be translated separately. Crucially, this means that we cannot swap out a page in one language in its entirety for a page in another language in its entirety. Instead, each individual element needs to be swapped out individually so as to only impact the language and not the structural composition of the page itself.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''2.2 Views require translation at a large number of call sites'''&amp;lt;br&amp;gt;&lt;br /&gt;
Given that a view is composed of individual elements, this also means that the computation of how to translate such an element such as a button’s text would need to be done separately for each element. This would result in not only a single centralized &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''3. Translation gaps'''&lt;br /&gt;
&lt;br /&gt;
== Scope ==&lt;br /&gt;
== Design ==&lt;br /&gt;
Proposed Solution&lt;br /&gt;
1. Language selection&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
'''''2. Rendering the language'''''&amp;lt;br&amp;gt;&lt;br /&gt;
Rendering the language&amp;lt;br&amp;gt;&lt;br /&gt;
Once we have determined the language in which to render the page, we now need to update the rails view code to actually generate the appropriate HTML in the target language. This is the responsibility of the view. However, currently, the actual content of the HTML is hardcoded in (red) English. For example:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;Summary Report for assignment: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;Team: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
As discussed earlier, “Views are composed of independent language elements” and so we cannot simply swap out the entire page content for a separate page in another language (Why? - See “swap out the entire view” in the alternative approaches section):&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;Rapport de synthèse pour l'affectation: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;Équipe: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;Instead, the better approach is to have a single unified view that dynamically changes based on the selected language:&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;&amp;lt;%=language==’en’ ? ‘Summary Report for assignment’ : ‘Rapport de synthèse pour l'affectation’&amp;gt;: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;&amp;lt;%=language==’en’ ? ‘Team’ : ‘Équipe’&amp;gt;: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;However this is clearly infeasible considering the number of call sites where we have to apply this logic. Thus, in order to maximize how concise the call site is, we can pull out this logic into a common helper function:&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;&amp;lt;%=localized(“report_summary.page_header”)&amp;gt;: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;&amp;lt;%=localized(“report_summary.team_label”)&amp;gt;: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;Here the assumption is that the localized(“key”) is aware of the currently selected language and that “report_summary.page_header” is the key for the header which is available in English and Hindi. The helper intelligently selects and returns the right text based on the currently selected language. Through this approach, we are able to render the view in multiple possible languages without any significant increase in the verbosity of the view.&lt;br /&gt;
&lt;br /&gt;
What’s more, is that the above problem is a common problem for user-facing applications and a standard library for doing the above and much more already exists for rails applications called i18n&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''''I18n - Internationalisation, How are we using I18n in Ruby on Rail'''''&amp;lt;br&amp;gt;&lt;br /&gt;
I18n is a ruby library/gem which helps us render the static string on the view dynamically. Dynamicity means that based on a local decision of choosing the current language of the view, the library returns the strings of that particular language at runtime.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
These strings, instead of hardcoding in the view.rb, are provided in external .yml files. Now at the View level, we can pass an id to the 't' function and the I18n library returns the string for that id of the current set language(called as locale). &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:i18n.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
For this purpose, we have to provide .yml files for each language and in those language-specific .yml, we have to provide a map of key-value pairs where the key is the id of the string and value is the string in that particular language. By default the language or locale is set to be English(:en). &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
THE GREATEST BENEFITS of using this library are - &amp;lt;br&amp;gt;&lt;br /&gt;
*The strings aren't hardcoded in the code/build. The strings are being fetched from external files which can be easily modified. For example, if one needs to change the text from 'Please Help' to 'Help', then one just needs to make a change in the .yml file and the change would reflect on the browser. For this change, we didn't need to redeploy the server. We just Decoupled the view when and where from what content is to be shown. &lt;br /&gt;
*Adding more languages is now super easy. Adding support for another language is just one line change in the config and adding a .yml file (having all the key-value pairs for the strings) for the new language. By doing this we can extend the language support as much as we want.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''''3. Translation gaps'''''&lt;br /&gt;
&amp;lt;br&amp;gt;Also, if the language is set to be Hindi or any other language but the key-value pair is not set for that particular string then, automatically the library returns the default which is the English text.&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;config.i18n.fallbacks = [:en]&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Alternate approaches ==&lt;br /&gt;
&lt;br /&gt;
'''1. Why not simply swap out the entire view for another language instead of each text?'''&amp;lt;br&amp;gt;&lt;br /&gt;
A view is an organized collection of multiple separate elements, views often involve dynamic generation and some level of sophistication. If we were to swap out one page in its entirety for another page this would often violate the '''DRY''' principle since we would have to have two separate implementations of the view in each language. Thus in the worst case, you have a complex view that has to be replicated dozens of times in various languages.&lt;br /&gt;
The majority of complexity of the page is not in the content itself but rather the code that executes to generate that content, thus it makes sense to instead maintain a single view and embed the language switching logic at each location where translation needs to occur to avoid replication of everything around it.&lt;br /&gt;
&lt;br /&gt;
'''2. Why did we pick i18n over implementing it ourselves?'''&amp;lt;br&amp;gt;&lt;br /&gt;
@ajulka&lt;br /&gt;
&lt;br /&gt;
'''3, Do we store the language preference, in the session or in the database?'''&amp;lt;br&amp;gt;&lt;br /&gt;
@rsabu&lt;br /&gt;
&lt;br /&gt;
== Use Case Diagram ==&lt;br /&gt;
== Major design patterns and principles used ==&lt;br /&gt;
&lt;br /&gt;
'''1. DRY: The i18n ‘t’ function'''&amp;lt;br&amp;gt;&lt;br /&gt;
We observe an extreme case of DRY with the t function of i18n.&lt;br /&gt;
For some background, the t function of the library takes in a key representing a text and returns the content referred to by that key in the preferred language of the user. It also performs many other functions such as falling back to a backup language if the translation for the preferred language has not been configured for that specific key. Thus since this logic has to be applied at every element of the view, it would behove us to extract this logic into a reusable function which is what the designers of the i18n library have employed&lt;br /&gt;
&lt;br /&gt;
'''2. Chain of responsibility'''&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Chainofresp.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The I18n library gives us an option to have many fall back options. When the required text for a given language is not found, we then move on to find the text for the next language in the chain and so on until we find it. And in the end we will put english as default language. So if the key value pair for the text is not found in none of the yml files then the text will be fetched from the English language yml file.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''3. Open closed principle &amp;amp; Strategy Pattern'''&amp;lt;br&amp;gt;&lt;br /&gt;
As discussed in the “Language selection&amp;quot; design proposal above, if the user has not selected a preferred language, we do not simply default the view to render in the application language (English). Instead, the project requirements state that for course specific screens such as the assignment view, we would need to render the view in the course’s language.&lt;br /&gt;
While we could implement this code into the application controller that checks the controller being access and accordingly applies overrides on the default language, this violates the open closed principle since we would need to extend this logic any time we introduce a new course specific screen. Instead a better approach is to delegate the decision of selecting the language to the view itself since the view would be most aware of whether the view is course specific or not. We can also preserve the DRYness through mix-ins.&lt;br /&gt;
&lt;br /&gt;
== Database Design ==&lt;br /&gt;
Database Modification ==&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
Test Details&lt;br /&gt;
Manual Testing&lt;br /&gt;
Scenario 1&lt;br /&gt;
Scenario 2&lt;br /&gt;
Scenario 3&lt;br /&gt;
Scenario 4&lt;br /&gt;
Scenario 5&lt;br /&gt;
== Future Scope==&lt;br /&gt;
'''1. Expand to more languages'''&amp;lt;br&amp;gt;&lt;br /&gt;
As part of this project we have targetted Hindi as a second language, however our work makes it easy to extend to other languages as well.&lt;br /&gt;
&lt;br /&gt;
'''2. Identify and implement the course language override on more course specific screens'''&amp;lt;br&amp;gt;&lt;br /&gt;
As part of this project, we have introduced a generic framework by which any view can provide a preferred language in which it should be rendered, this is required by this project for the course language feature set by the instructor.&lt;br /&gt;
We have currently made the assignment screen display in the course’s language, however other screens such as the “Your work” screen and so on are also specific to the course could also be rendered in the course language when the user has not provided a preference.&lt;br /&gt;
&lt;br /&gt;
== Team ==&lt;br /&gt;
&lt;br /&gt;
'''Team Members'''&lt;br /&gt;
&lt;br /&gt;
Reuben M. V. John [[mailto:rmjohn2@ncsu.edu rmjohn2@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Renji Joseph Sabu [[mailto:rsabu@ncsu.edu rsabu@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Ashwin Das [[mailto:adas9@ncsu.edu adas9@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Arnav Julka [[mailto:ajulka@ncsu.edu ajulka@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Mentor'''&lt;br /&gt;
&lt;br /&gt;
Jialin Cui [[mailto:jcui9@ncsu.edu jcui9@ncsu.edu]]&lt;/div&gt;</summary>
		<author><name>Ajulka</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Twophase2.jpg&amp;diff=140535</id>
		<title>File:Twophase2.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Twophase2.jpg&amp;diff=140535"/>
		<updated>2021-11-03T01:48:16Z</updated>

		<summary type="html">&lt;p&gt;Ajulka: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Ajulka</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Twophase.png&amp;diff=140534</id>
		<title>File:Twophase.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Twophase.png&amp;diff=140534"/>
		<updated>2021-11-03T01:45:30Z</updated>

		<summary type="html">&lt;p&gt;Ajulka: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Ajulka</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization&amp;diff=140533</id>
		<title>CSC/ECE 517 Fall 2021 - E2159. Expertiza internationalization</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization&amp;diff=140533"/>
		<updated>2021-11-03T01:44:18Z</updated>

		<summary type="html">&lt;p&gt;Ajulka: /* Major design patterns and principles used */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction - Purpose &amp;amp; Problem ==&lt;br /&gt;
&lt;br /&gt;
Currently, all Expertiza screens can only be viewed in English. Many Expertiza users are from other countries. This is a problem since this limits the accessibility of Expertiza. An important step in solving this problem is by making Expertiza available in more languages, which is a form of internationalization.&lt;br /&gt;
W3C defines [https://www.w3.org/International/questions/qa-i18n internationalization] as “''the design and development of a product, application or document content that enables easy localization for target audiences that vary in culture, region, or language.''”&lt;br /&gt;
&lt;br /&gt;
[[File:country_pie.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
Fig: Survey of home country of Expertiza users for a given course&lt;br /&gt;
&lt;br /&gt;
Breaking down internationalization into 3 sequential subproblems:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Scope:''' The scope of this project is limited however only to static strings. i.e. user-generated content will not be automatically translated to other languages.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''1. Language selection'''&lt;br /&gt;
&lt;br /&gt;
'''2. Rendering the language'''&amp;lt;br&amp;gt;&lt;br /&gt;
'''How do we go about rendering the screen in that language?''' &amp;lt;br&amp;gt;&lt;br /&gt;
In the previous step, we’ve identified the language in which a view is to be rendered. It is important to note that this language may not only differ for a different user, but also for a different page for the same user. The question now becomes, how do we render the screen in this language? To tackle this question, we explore 2 fundamental concepts:&amp;lt;br&amp;gt;&lt;br /&gt;
'''Views are composed of independent language elements'''&amp;lt;br&amp;gt;&lt;br /&gt;
While this is something we typically take for granted, it becomes especially important in the context of translation. That is, a view is not a single contiguous block of text, nor is it an atomic visualization of information (unlike a screenshot), but rather a carefully organized collection of individual elements such as texts, buttons, etc that each contain language that needs to be translated separately. Crucially, this means that we cannot swap out a page in one language in its entirety for a page in another language in its entirety. Instead, each individual element needs to be swapped out individually so as to only impact the language and not the structural composition of the page itself.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''*Views require translation at a large number of call sites'''&amp;lt;br&amp;gt;&lt;br /&gt;
Given that a view is composed of individual elements, this also means that the computation of how to translate such an element such as a button’s text would need to be done separately for each element. This would result in not only a single centralized &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''3. Translation gaps'''&lt;br /&gt;
&lt;br /&gt;
== Scope ==&lt;br /&gt;
== Design ==&lt;br /&gt;
Proposed Solution&lt;br /&gt;
1. Language selection&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
'''''2. Rendering the language'''''&amp;lt;br&amp;gt;&lt;br /&gt;
Rendering the language&amp;lt;br&amp;gt;&lt;br /&gt;
Once we have determined the language in which to render the page, we now need to update the rails view code to actually generate the appropriate HTML in the target language. This is the responsibility of the view. However, currently, the actual content of the HTML is hardcoded in (red) English. For example:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;Summary Report for assignment: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;Team: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
As discussed earlier, “Views are composed of independent language elements” and so we cannot simply swap out the entire page content for a separate page in another language (Why? - See “swap out the entire view” in the alternative approaches section):&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;Rapport de synthèse pour l'affectation: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;Équipe: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;Instead, the better approach is to have a single unified view that dynamically changes based on the selected language:&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;&amp;lt;%=language==’en’ ? ‘Summary Report for assignment’ : ‘Rapport de synthèse pour l'affectation’&amp;gt;: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;&amp;lt;%=language==’en’ ? ‘Team’ : ‘Équipe’&amp;gt;: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;However this is clearly infeasible considering the number of call sites where we have to apply this logic. Thus, in order to maximize how concise the call site is, we can pull out this logic into a common helper function:&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;&amp;lt;%=localized(“report_summary.page_header”)&amp;gt;: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;&amp;lt;%=localized(“report_summary.team_label”)&amp;gt;: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;Here the assumption is that the localized(“key”) is aware of the currently selected language and that “report_summary.page_header” is the key for the header which is available in English and Hindi. The helper intelligently selects and returns the right text based on the currently selected language. Through this approach, we are able to render the view in multiple possible languages without any significant increase in the verbosity of the view.&lt;br /&gt;
&lt;br /&gt;
What’s more, is that the above problem is a common problem for user-facing applications and a standard library for doing the above and much more already exists for rails applications called i18n&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''''I18n - Internationalisation, How are we using I18n in Ruby on Rail'''''&amp;lt;br&amp;gt;&lt;br /&gt;
I18n is a ruby library/gem which helps us render the static string on the view dynamically. Dynamicity means that based on a local decision of choosing the current language of the view, the library returns the strings of that particular language at runtime.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
These strings, instead of hardcoding in the view.rb, are provided in external .yml files. Now at the View level, we can pass an id to the 't' function and the I18n library returns the string for that id of the current set language(called as locale). &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:i18n.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
For this purpose, we have to provide .yml files for each language and in those language-specific .yml, we have to provide a map of key-value pairs where the key is the id of the string and value is the string in that particular language. By default the language or locale is set to be English(:en). &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
THE GREATEST BENEFITS of using this library are - &amp;lt;br&amp;gt;&lt;br /&gt;
*The strings aren't hardcoded in the code/build. The strings are being fetched from external files which can be easily modified. For example, if one needs to change the text from 'Please Help' to 'Help', then one just needs to make a change in the .yml file and the change would reflect on the browser. For this change, we didn't need to redeploy the server. We just Decoupled the view when and where from what content is to be shown. &lt;br /&gt;
*Adding more languages is now super easy. Adding support for another language is just one line change in the config and adding a .yml file (having all the key-value pairs for the strings) for the new language. By doing this we can extend the language support as much as we want.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''''3. Translation gaps'''''&lt;br /&gt;
&amp;lt;br&amp;gt;Also, if the language is set to be Hindi or any other language but the key-value pair is not set for that particular string then, automatically the library returns the default which is the English text.&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;config.i18n.fallbacks = [:en]&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Alternate approaches ==&lt;br /&gt;
&lt;br /&gt;
'''1. Why not simply swap out the entire view for another language instead of each text?'''&amp;lt;br&amp;gt;&lt;br /&gt;
A view is an organized collection of multiple separate elements, views often involve dynamic generation and some level of sophistication. If we were to swap out one page in its entirety for another page this would often violate the '''DRY''' principle since we would have to have two separate implementations of the view in each language. Thus in the worst case, you have a complex view that has to be replicated dozens of times in various languages.&lt;br /&gt;
The majority of complexity of the page is not in the content itself but rather the code that executes to generate that content, thus it makes sense to instead maintain a single view and embed the language switching logic at each location where translation needs to occur to avoid replication of everything around it.&lt;br /&gt;
&lt;br /&gt;
'''2. Why did we pick i18n over implementing it ourselves?'''&amp;lt;br&amp;gt;&lt;br /&gt;
@ajulka&lt;br /&gt;
&lt;br /&gt;
'''3, Do we store the language preference, in the session or in the database?'''&amp;lt;br&amp;gt;&lt;br /&gt;
@rsabu&lt;br /&gt;
&lt;br /&gt;
== Use Case Diagram ==&lt;br /&gt;
== Major design patterns and principles used ==&lt;br /&gt;
&lt;br /&gt;
'''1. DRY: The i18n ‘t’ function'''&amp;lt;br&amp;gt;&lt;br /&gt;
We observe an extreme case of DRY with the t function of i18n.&lt;br /&gt;
For some background, the t function of the library takes in a key representing a text and returns the content referred to by that key in the preferred language of the user. It also performs many other functions such as falling back to a backup language if the translation for the preferred language has not been configured for that specific key. Thus since this logic has to be applied at every element of the view, it would behove us to extract this logic into a reusable function which is what the designers of the i18n library have employed&lt;br /&gt;
&lt;br /&gt;
'''2. Chain of responsibility'''&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Chainofresp.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The I18n library gives us an option to have many fall back options. When the required text for a given language is not found, we then move on to find the text for the next language in the chain and so on until we find it. And in the end we will put english as default language. So if the key value pair for the text is not found in none of the yml files then the text will be fetched from the English language yml file.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''3. Open closed principle &amp;amp; Strategy Pattern'''&amp;lt;br&amp;gt;&lt;br /&gt;
As discussed in the “Language selection&amp;quot; design proposal above, if the user has not selected a preferred language, we do not simply default the view to render in the application language (English). Instead, the project requirements state that for course specific screens such as the assignment view, we would need to render the view in the course’s language.&lt;br /&gt;
While we could implement this code into the application controller that checks the controller being access and accordingly applies overrides on the default language, this violates the open closed principle since we would need to extend this logic any time we introduce a new course specific screen. Instead a better approach is to delegate the decision of selecting the language to the view itself since the view would be most aware of whether the view is course specific or not. We can also preserve the DRYness through mix-ins.&lt;br /&gt;
&lt;br /&gt;
== Database Design ==&lt;br /&gt;
Database Modification ==&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
Test Details&lt;br /&gt;
Manual Testing&lt;br /&gt;
Scenario 1&lt;br /&gt;
Scenario 2&lt;br /&gt;
Scenario 3&lt;br /&gt;
Scenario 4&lt;br /&gt;
Scenario 5&lt;br /&gt;
== Future Scope==&lt;br /&gt;
'''1. Expand to more languages'''&amp;lt;br&amp;gt;&lt;br /&gt;
As part of this project we have targetted Hindi as a second language, however our work makes it easy to extend to other languages as well.&lt;br /&gt;
&lt;br /&gt;
'''2. Identify and implement the course language override on more course specific screens'''&amp;lt;br&amp;gt;&lt;br /&gt;
As part of this project, we have introduced a generic framework by which any view can provide a preferred language in which it should be rendered, this is required by this project for the course language feature set by the instructor.&lt;br /&gt;
We have currently made the assignment screen display in the course’s language, however other screens such as the “Your work” screen and so on are also specific to the course could also be rendered in the course language when the user has not provided a preference.&lt;br /&gt;
&lt;br /&gt;
== Team ==&lt;br /&gt;
&lt;br /&gt;
'''Team Members'''&lt;br /&gt;
&lt;br /&gt;
Reuben M. V. John [[mailto:rmjohn2@ncsu.edu rmjohn2@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Renji Joseph Sabu [[mailto:rsabu@ncsu.edu rsabu@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Ashwin Das [[mailto:adas9@ncsu.edu adas9@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Arnav Julka [[mailto:ajulka@ncsu.edu ajulka@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Mentor'''&lt;br /&gt;
&lt;br /&gt;
Jialin Cui [[mailto:jcui9@ncsu.edu jcui9@ncsu.edu]]&lt;/div&gt;</summary>
		<author><name>Ajulka</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Chainofresp.png&amp;diff=140532</id>
		<title>File:Chainofresp.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Chainofresp.png&amp;diff=140532"/>
		<updated>2021-11-03T01:43:47Z</updated>

		<summary type="html">&lt;p&gt;Ajulka: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Ajulka</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization&amp;diff=140531</id>
		<title>CSC/ECE 517 Fall 2021 - E2159. Expertiza internationalization</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization&amp;diff=140531"/>
		<updated>2021-11-03T01:43:35Z</updated>

		<summary type="html">&lt;p&gt;Ajulka: /* Major design patterns and principles used */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction - Purpose &amp;amp; Problem ==&lt;br /&gt;
&lt;br /&gt;
Currently, all Expertiza screens can only be viewed in English. Many Expertiza users are from other countries. This is a problem since this limits the accessibility of Expertiza. An important step in solving this problem is by making Expertiza available in more languages, which is a form of internationalization.&lt;br /&gt;
W3C defines [https://www.w3.org/International/questions/qa-i18n internationalization] as “''the design and development of a product, application or document content that enables easy localization for target audiences that vary in culture, region, or language.''”&lt;br /&gt;
&lt;br /&gt;
[[File:country_pie.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
Fig: Survey of home country of Expertiza users for a given course&lt;br /&gt;
&lt;br /&gt;
Breaking down internationalization into 3 sequential subproblems:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Scope:''' The scope of this project is limited however only to static strings. i.e. user-generated content will not be automatically translated to other languages.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''1. Language selection'''&lt;br /&gt;
&lt;br /&gt;
'''2. Rendering the language'''&amp;lt;br&amp;gt;&lt;br /&gt;
'''How do we go about rendering the screen in that language?''' &amp;lt;br&amp;gt;&lt;br /&gt;
In the previous step, we’ve identified the language in which a view is to be rendered. It is important to note that this language may not only differ for a different user, but also for a different page for the same user. The question now becomes, how do we render the screen in this language? To tackle this question, we explore 2 fundamental concepts:&amp;lt;br&amp;gt;&lt;br /&gt;
'''Views are composed of independent language elements'''&amp;lt;br&amp;gt;&lt;br /&gt;
While this is something we typically take for granted, it becomes especially important in the context of translation. That is, a view is not a single contiguous block of text, nor is it an atomic visualization of information (unlike a screenshot), but rather a carefully organized collection of individual elements such as texts, buttons, etc that each contain language that needs to be translated separately. Crucially, this means that we cannot swap out a page in one language in its entirety for a page in another language in its entirety. Instead, each individual element needs to be swapped out individually so as to only impact the language and not the structural composition of the page itself.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''*Views require translation at a large number of call sites'''&amp;lt;br&amp;gt;&lt;br /&gt;
Given that a view is composed of individual elements, this also means that the computation of how to translate such an element such as a button’s text would need to be done separately for each element. This would result in not only a single centralized &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''3. Translation gaps'''&lt;br /&gt;
&lt;br /&gt;
== Scope ==&lt;br /&gt;
== Design ==&lt;br /&gt;
Proposed Solution&lt;br /&gt;
1. Language selection&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
'''''2. Rendering the language'''''&amp;lt;br&amp;gt;&lt;br /&gt;
Rendering the language&amp;lt;br&amp;gt;&lt;br /&gt;
Once we have determined the language in which to render the page, we now need to update the rails view code to actually generate the appropriate HTML in the target language. This is the responsibility of the view. However, currently, the actual content of the HTML is hardcoded in (red) English. For example:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;Summary Report for assignment: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;Team: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
As discussed earlier, “Views are composed of independent language elements” and so we cannot simply swap out the entire page content for a separate page in another language (Why? - See “swap out the entire view” in the alternative approaches section):&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;Rapport de synthèse pour l'affectation: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;Équipe: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;Instead, the better approach is to have a single unified view that dynamically changes based on the selected language:&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;&amp;lt;%=language==’en’ ? ‘Summary Report for assignment’ : ‘Rapport de synthèse pour l'affectation’&amp;gt;: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;&amp;lt;%=language==’en’ ? ‘Team’ : ‘Équipe’&amp;gt;: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;However this is clearly infeasible considering the number of call sites where we have to apply this logic. Thus, in order to maximize how concise the call site is, we can pull out this logic into a common helper function:&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;&amp;lt;%=localized(“report_summary.page_header”)&amp;gt;: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;&amp;lt;%=localized(“report_summary.team_label”)&amp;gt;: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;Here the assumption is that the localized(“key”) is aware of the currently selected language and that “report_summary.page_header” is the key for the header which is available in English and Hindi. The helper intelligently selects and returns the right text based on the currently selected language. Through this approach, we are able to render the view in multiple possible languages without any significant increase in the verbosity of the view.&lt;br /&gt;
&lt;br /&gt;
What’s more, is that the above problem is a common problem for user-facing applications and a standard library for doing the above and much more already exists for rails applications called i18n&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''''I18n - Internationalisation, How are we using I18n in Ruby on Rail'''''&amp;lt;br&amp;gt;&lt;br /&gt;
I18n is a ruby library/gem which helps us render the static string on the view dynamically. Dynamicity means that based on a local decision of choosing the current language of the view, the library returns the strings of that particular language at runtime.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
These strings, instead of hardcoding in the view.rb, are provided in external .yml files. Now at the View level, we can pass an id to the 't' function and the I18n library returns the string for that id of the current set language(called as locale). &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:i18n.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
For this purpose, we have to provide .yml files for each language and in those language-specific .yml, we have to provide a map of key-value pairs where the key is the id of the string and value is the string in that particular language. By default the language or locale is set to be English(:en). &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
THE GREATEST BENEFITS of using this library are - &amp;lt;br&amp;gt;&lt;br /&gt;
*The strings aren't hardcoded in the code/build. The strings are being fetched from external files which can be easily modified. For example, if one needs to change the text from 'Please Help' to 'Help', then one just needs to make a change in the .yml file and the change would reflect on the browser. For this change, we didn't need to redeploy the server. We just Decoupled the view when and where from what content is to be shown. &lt;br /&gt;
*Adding more languages is now super easy. Adding support for another language is just one line change in the config and adding a .yml file (having all the key-value pairs for the strings) for the new language. By doing this we can extend the language support as much as we want.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''''3. Translation gaps'''''&lt;br /&gt;
&amp;lt;br&amp;gt;Also, if the language is set to be Hindi or any other language but the key-value pair is not set for that particular string then, automatically the library returns the default which is the English text.&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;config.i18n.fallbacks = [:en]&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Alternate approaches ==&lt;br /&gt;
&lt;br /&gt;
'''1. Why not simply swap out the entire view for another language instead of each text?'''&amp;lt;br&amp;gt;&lt;br /&gt;
A view is an organized collection of multiple separate elements, views often involve dynamic generation and some level of sophistication. If we were to swap out one page in its entirety for another page this would often violate the '''DRY''' principle since we would have to have two separate implementations of the view in each language. Thus in the worst case, you have a complex view that has to be replicated dozens of times in various languages.&lt;br /&gt;
The majority of complexity of the page is not in the content itself but rather the code that executes to generate that content, thus it makes sense to instead maintain a single view and embed the language switching logic at each location where translation needs to occur to avoid replication of everything around it.&lt;br /&gt;
&lt;br /&gt;
'''2. Why did we pick i18n over implementing it ourselves?'''&amp;lt;br&amp;gt;&lt;br /&gt;
@ajulka&lt;br /&gt;
&lt;br /&gt;
'''3, Do we store the language preference, in the session or in the database?'''&amp;lt;br&amp;gt;&lt;br /&gt;
@rsabu&lt;br /&gt;
&lt;br /&gt;
== Use Case Diagram ==&lt;br /&gt;
== Major design patterns and principles used ==&lt;br /&gt;
&lt;br /&gt;
'''1. DRY: The i18n ‘t’ function'''&amp;lt;br&amp;gt;&lt;br /&gt;
We observe an extreme case of DRY with the t function of i18n.&lt;br /&gt;
For some background, the t function of the library takes in a key representing a text and returns the content referred to by that key in the preferred language of the user. It also performs many other functions such as falling back to a backup language if the translation for the preferred language has not been configured for that specific key. Thus since this logic has to be applied at every element of the view, it would behove us to extract this logic into a reusable function which is what the designers of the i18n library have employed&lt;br /&gt;
&lt;br /&gt;
'''2. Chain of responsibility'''&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:chainofresp.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The I18n library gives us an option to have many fall back options. When the required text for a given language is not found, we then move on to find the text for the next language in the chain and so on until we find it. And in the end we will put english as default language. So if the key value pair for the text is not found in none of the yml files then the text will be fetched from the English language yml file.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''3. Open closed principle &amp;amp; Strategy Pattern'''&amp;lt;br&amp;gt;&lt;br /&gt;
As discussed in the “Language selection&amp;quot; design proposal above, if the user has not selected a preferred language, we do not simply default the view to render in the application language (English). Instead, the project requirements state that for course specific screens such as the assignment view, we would need to render the view in the course’s language.&lt;br /&gt;
While we could implement this code into the application controller that checks the controller being access and accordingly applies overrides on the default language, this violates the open closed principle since we would need to extend this logic any time we introduce a new course specific screen. Instead a better approach is to delegate the decision of selecting the language to the view itself since the view would be most aware of whether the view is course specific or not. We can also preserve the DRYness through mix-ins.&lt;br /&gt;
&lt;br /&gt;
== Database Design ==&lt;br /&gt;
Database Modification ==&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
Test Details&lt;br /&gt;
Manual Testing&lt;br /&gt;
Scenario 1&lt;br /&gt;
Scenario 2&lt;br /&gt;
Scenario 3&lt;br /&gt;
Scenario 4&lt;br /&gt;
Scenario 5&lt;br /&gt;
== Future Scope==&lt;br /&gt;
'''1. Expand to more languages'''&amp;lt;br&amp;gt;&lt;br /&gt;
As part of this project we have targetted Hindi as a second language, however our work makes it easy to extend to other languages as well.&lt;br /&gt;
&lt;br /&gt;
'''2. Identify and implement the course language override on more course specific screens'''&amp;lt;br&amp;gt;&lt;br /&gt;
As part of this project, we have introduced a generic framework by which any view can provide a preferred language in which it should be rendered, this is required by this project for the course language feature set by the instructor.&lt;br /&gt;
We have currently made the assignment screen display in the course’s language, however other screens such as the “Your work” screen and so on are also specific to the course could also be rendered in the course language when the user has not provided a preference.&lt;br /&gt;
&lt;br /&gt;
== Team ==&lt;br /&gt;
&lt;br /&gt;
'''Team Members'''&lt;br /&gt;
&lt;br /&gt;
Reuben M. V. John [[mailto:rmjohn2@ncsu.edu rmjohn2@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Renji Joseph Sabu [[mailto:rsabu@ncsu.edu rsabu@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Ashwin Das [[mailto:adas9@ncsu.edu adas9@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Arnav Julka [[mailto:ajulka@ncsu.edu ajulka@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Mentor'''&lt;br /&gt;
&lt;br /&gt;
Jialin Cui [[mailto:jcui9@ncsu.edu jcui9@ncsu.edu]]&lt;/div&gt;</summary>
		<author><name>Ajulka</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization&amp;diff=140529</id>
		<title>CSC/ECE 517 Fall 2021 - E2159. Expertiza internationalization</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization&amp;diff=140529"/>
		<updated>2021-11-03T01:39:50Z</updated>

		<summary type="html">&lt;p&gt;Ajulka: /* Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction - Purpose &amp;amp; Problem ==&lt;br /&gt;
&lt;br /&gt;
Currently, all Expertiza screens can only be viewed in English. Many Expertiza users are from other countries. This is a problem since this limits the accessibility of Expertiza. An important step in solving this problem is by making Expertiza available in more languages, which is a form of internationalization.&lt;br /&gt;
W3C defines [https://www.w3.org/International/questions/qa-i18n internationalization] as “''the design and development of a product, application or document content that enables easy localization for target audiences that vary in culture, region, or language.''”&lt;br /&gt;
&lt;br /&gt;
[[File:country_pie.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
Fig: Survey of home country of Expertiza users for a given course&lt;br /&gt;
&lt;br /&gt;
Breaking down internationalization into 3 sequential subproblems:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Scope:''' The scope of this project is limited however only to static strings. i.e. user-generated content will not be automatically translated to other languages.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''1. Language selection'''&lt;br /&gt;
&lt;br /&gt;
'''2. Rendering the language'''&amp;lt;br&amp;gt;&lt;br /&gt;
'''How do we go about rendering the screen in that language?''' &amp;lt;br&amp;gt;&lt;br /&gt;
In the previous step, we’ve identified the language in which a view is to be rendered. It is important to note that this language may not only differ for a different user, but also for a different page for the same user. The question now becomes, how do we render the screen in this language? To tackle this question, we explore 2 fundamental concepts:&amp;lt;br&amp;gt;&lt;br /&gt;
'''Views are composed of independent language elements'''&amp;lt;br&amp;gt;&lt;br /&gt;
While this is something we typically take for granted, it becomes especially important in the context of translation. That is, a view is not a single contiguous block of text, nor is it an atomic visualization of information (unlike a screenshot), but rather a carefully organized collection of individual elements such as texts, buttons, etc that each contain language that needs to be translated separately. Crucially, this means that we cannot swap out a page in one language in its entirety for a page in another language in its entirety. Instead, each individual element needs to be swapped out individually so as to only impact the language and not the structural composition of the page itself.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''*Views require translation at a large number of call sites'''&amp;lt;br&amp;gt;&lt;br /&gt;
Given that a view is composed of individual elements, this also means that the computation of how to translate such an element such as a button’s text would need to be done separately for each element. This would result in not only a single centralized &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''3. Translation gaps'''&lt;br /&gt;
&lt;br /&gt;
== Scope ==&lt;br /&gt;
== Design ==&lt;br /&gt;
Proposed Solution&lt;br /&gt;
1. Language selection&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
'''''2. Rendering the language'''''&amp;lt;br&amp;gt;&lt;br /&gt;
Rendering the language&amp;lt;br&amp;gt;&lt;br /&gt;
Once we have determined the language in which to render the page, we now need to update the rails view code to actually generate the appropriate HTML in the target language. This is the responsibility of the view. However, currently, the actual content of the HTML is hardcoded in (red) English. For example:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;Summary Report for assignment: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;Team: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
As discussed earlier, “Views are composed of independent language elements” and so we cannot simply swap out the entire page content for a separate page in another language (Why? - See “swap out the entire view” in the alternative approaches section):&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;Rapport de synthèse pour l'affectation: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;Équipe: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;Instead, the better approach is to have a single unified view that dynamically changes based on the selected language:&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;&amp;lt;%=language==’en’ ? ‘Summary Report for assignment’ : ‘Rapport de synthèse pour l'affectation’&amp;gt;: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;&amp;lt;%=language==’en’ ? ‘Team’ : ‘Équipe’&amp;gt;: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;However this is clearly infeasible considering the number of call sites where we have to apply this logic. Thus, in order to maximize how concise the call site is, we can pull out this logic into a common helper function:&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;&amp;lt;%=localized(“report_summary.page_header”)&amp;gt;: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;&amp;lt;%=localized(“report_summary.team_label”)&amp;gt;: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;Here the assumption is that the localized(“key”) is aware of the currently selected language and that “report_summary.page_header” is the key for the header which is available in English and Hindi. The helper intelligently selects and returns the right text based on the currently selected language. Through this approach, we are able to render the view in multiple possible languages without any significant increase in the verbosity of the view.&lt;br /&gt;
&lt;br /&gt;
What’s more, is that the above problem is a common problem for user-facing applications and a standard library for doing the above and much more already exists for rails applications called i18n&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''''I18n - Internationalisation, How are we using I18n in Ruby on Rail'''''&amp;lt;br&amp;gt;&lt;br /&gt;
I18n is a ruby library/gem which helps us render the static string on the view dynamically. Dynamicity means that based on a local decision of choosing the current language of the view, the library returns the strings of that particular language at runtime.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
These strings, instead of hardcoding in the view.rb, are provided in external .yml files. Now at the View level, we can pass an id to the 't' function and the I18n library returns the string for that id of the current set language(called as locale). &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:i18n.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
For this purpose, we have to provide .yml files for each language and in those language-specific .yml, we have to provide a map of key-value pairs where the key is the id of the string and value is the string in that particular language. By default the language or locale is set to be English(:en). &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
THE GREATEST BENEFITS of using this library are - &amp;lt;br&amp;gt;&lt;br /&gt;
*The strings aren't hardcoded in the code/build. The strings are being fetched from external files which can be easily modified. For example, if one needs to change the text from 'Please Help' to 'Help', then one just needs to make a change in the .yml file and the change would reflect on the browser. For this change, we didn't need to redeploy the server. We just Decoupled the view when and where from what content is to be shown. &lt;br /&gt;
*Adding more languages is now super easy. Adding support for another language is just one line change in the config and adding a .yml file (having all the key-value pairs for the strings) for the new language. By doing this we can extend the language support as much as we want.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''''3. Translation gaps'''''&lt;br /&gt;
&amp;lt;br&amp;gt;Also, if the language is set to be Hindi or any other language but the key-value pair is not set for that particular string then, automatically the library returns the default which is the English text.&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;config.i18n.fallbacks = [:en]&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Alternate approaches ==&lt;br /&gt;
&lt;br /&gt;
'''1. Why not simply swap out the entire view for another language instead of each text?'''&amp;lt;br&amp;gt;&lt;br /&gt;
A view is an organized collection of multiple separate elements, views often involve dynamic generation and some level of sophistication. If we were to swap out one page in its entirety for another page this would often violate the '''DRY''' principle since we would have to have two separate implementations of the view in each language. Thus in the worst case, you have a complex view that has to be replicated dozens of times in various languages.&lt;br /&gt;
The majority of complexity of the page is not in the content itself but rather the code that executes to generate that content, thus it makes sense to instead maintain a single view and embed the language switching logic at each location where translation needs to occur to avoid replication of everything around it.&lt;br /&gt;
&lt;br /&gt;
'''2. Why did we pick i18n over implementing it ourselves?'''&amp;lt;br&amp;gt;&lt;br /&gt;
@ajulka&lt;br /&gt;
&lt;br /&gt;
'''3, Do we store the language preference, in the session or in the database?'''&amp;lt;br&amp;gt;&lt;br /&gt;
@rsabu&lt;br /&gt;
&lt;br /&gt;
== Use Case Diagram ==&lt;br /&gt;
== Major design patterns and principles used ==&lt;br /&gt;
&lt;br /&gt;
'''1. DRY: The i18n ‘t’ function'''&amp;lt;br&amp;gt;&lt;br /&gt;
We observe an extreme case of DRY with the t function of i18n.&lt;br /&gt;
For some background, the t function of the library takes in a key representing a text and returns the content referred to by that key in the preferred language of the user. It also performs many other functions such as falling back to a backup language if the translation for the preferred language has not been configured for that specific key. Thus since this logic has to be applied at every element of the view, it would behove us to extract this logic into a reusable function which is what the designers of the i18n library have employed&lt;br /&gt;
&lt;br /&gt;
'''2. Chain of responsibility'''&amp;lt;br&amp;gt;&lt;br /&gt;
@ajulka&lt;br /&gt;
&lt;br /&gt;
'''3. Open closed principle &amp;amp; Strategy Pattern'''&amp;lt;br&amp;gt;&lt;br /&gt;
As discussed in the “Language selection&amp;quot; design proposal above, if the user has not selected a preferred language, we do not simply default the view to render in the application language (English). Instead, the project requirements state that for course specific screens such as the assignment view, we would need to render the view in the course’s language.&lt;br /&gt;
While we could implement this code into the application controller that checks the controller being access and accordingly applies overrides on the default language, this violates the open closed principle since we would need to extend this logic any time we introduce a new course specific screen. Instead a better approach is to delegate the decision of selecting the language to the view itself since the view would be most aware of whether the view is course specific or not. We can also preserve the DRYness through mix-ins.&lt;br /&gt;
&lt;br /&gt;
== Database Design ==&lt;br /&gt;
Database Modification ==&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
Test Details&lt;br /&gt;
Manual Testing&lt;br /&gt;
Scenario 1&lt;br /&gt;
Scenario 2&lt;br /&gt;
Scenario 3&lt;br /&gt;
Scenario 4&lt;br /&gt;
Scenario 5&lt;br /&gt;
== Future Scope==&lt;br /&gt;
'''1. Expand to more languages'''&amp;lt;br&amp;gt;&lt;br /&gt;
As part of this project we have targetted Hindi as a second language, however our work makes it easy to extend to other languages as well.&lt;br /&gt;
&lt;br /&gt;
'''2. Identify and implement the course language override on more course specific screens'''&amp;lt;br&amp;gt;&lt;br /&gt;
As part of this project, we have introduced a generic framework by which any view can provide a preferred language in which it should be rendered, this is required by this project for the course language feature set by the instructor.&lt;br /&gt;
We have currently made the assignment screen display in the course’s language, however other screens such as the “Your work” screen and so on are also specific to the course could also be rendered in the course language when the user has not provided a preference.&lt;br /&gt;
&lt;br /&gt;
== Team ==&lt;br /&gt;
&lt;br /&gt;
'''Team Members'''&lt;br /&gt;
&lt;br /&gt;
Reuben M. V. John [[mailto:rmjohn2@ncsu.edu rmjohn2@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Renji Joseph Sabu [[mailto:rsabu@ncsu.edu rsabu@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Ashwin Das [[mailto:adas9@ncsu.edu adas9@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Arnav Julka [[mailto:ajulka@ncsu.edu ajulka@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Mentor'''&lt;br /&gt;
&lt;br /&gt;
Jialin Cui [[mailto:jcui9@ncsu.edu jcui9@ncsu.edu]]&lt;/div&gt;</summary>
		<author><name>Ajulka</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization&amp;diff=140528</id>
		<title>CSC/ECE 517 Fall 2021 - E2159. Expertiza internationalization</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization&amp;diff=140528"/>
		<updated>2021-11-03T01:39:25Z</updated>

		<summary type="html">&lt;p&gt;Ajulka: /* Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction - Purpose &amp;amp; Problem ==&lt;br /&gt;
&lt;br /&gt;
Currently, all Expertiza screens can only be viewed in English. Many Expertiza users are from other countries. This is a problem since this limits the accessibility of Expertiza. An important step in solving this problem is by making Expertiza available in more languages, which is a form of internationalization.&lt;br /&gt;
W3C defines [https://www.w3.org/International/questions/qa-i18n internationalization] as “''the design and development of a product, application or document content that enables easy localization for target audiences that vary in culture, region, or language.''”&lt;br /&gt;
&lt;br /&gt;
[[File:country_pie.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
Fig: Survey of home country of Expertiza users for a given course&lt;br /&gt;
&lt;br /&gt;
Breaking down internationalization into 3 sequential subproblems:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Scope:''' The scope of this project is limited however only to static strings. i.e. user-generated content will not be automatically translated to other languages.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''1. Language selection'''&lt;br /&gt;
&lt;br /&gt;
'''2. Rendering the language'''&amp;lt;br&amp;gt;&lt;br /&gt;
'''How do we go about rendering the screen in that language?''' &amp;lt;br&amp;gt;&lt;br /&gt;
In the previous step, we’ve identified the language in which a view is to be rendered. It is important to note that this language may not only differ for a different user, but also for a different page for the same user. The question now becomes, how do we render the screen in this language? To tackle this question, we explore 2 fundamental concepts:&amp;lt;br&amp;gt;&lt;br /&gt;
'''Views are composed of independent language elements'''&amp;lt;br&amp;gt;&lt;br /&gt;
While this is something we typically take for granted, it becomes especially important in the context of translation. That is, a view is not a single contiguous block of text, nor is it an atomic visualization of information (unlike a screenshot), but rather a carefully organized collection of individual elements such as texts, buttons, etc that each contain language that needs to be translated separately. Crucially, this means that we cannot swap out a page in one language in its entirety for a page in another language in its entirety. Instead, each individual element needs to be swapped out individually so as to only impact the language and not the structural composition of the page itself.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''*Views require translation at a large number of call sites'''&amp;lt;br&amp;gt;&lt;br /&gt;
Given that a view is composed of individual elements, this also means that the computation of how to translate such an element such as a button’s text would need to be done separately for each element. This would result in not only a single centralized &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''3. Translation gaps'''&lt;br /&gt;
&lt;br /&gt;
== Scope ==&lt;br /&gt;
== Design ==&lt;br /&gt;
Proposed Solution&lt;br /&gt;
1. Language selection&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
'''''2. Rendering the language'''''&amp;lt;br&amp;gt;&lt;br /&gt;
Rendering the language&amp;lt;br&amp;gt;&lt;br /&gt;
Once we have determined the language in which to render the page, we now need to update the rails view code to actually generate the appropriate HTML in the target language. This is the responsibility of the view. However, currently, the actual content of the HTML is hardcoded in (red) English. For example:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;Summary Report for assignment: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;Team: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
As discussed earlier, “Views are composed of independent language elements” and so we cannot simply swap out the entire page content for a separate page in another language (Why? - See “swap out the entire view” in the alternative approaches section):&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;Rapport de synthèse pour l'affectation: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;Équipe: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;Instead, the better approach is to have a single unified view that dynamically changes based on the selected language:&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;&amp;lt;%=language==’en’ ? ‘Summary Report for assignment’ : ‘Rapport de synthèse pour l'affectation’&amp;gt;: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;&amp;lt;%=language==’en’ ? ‘Team’ : ‘Équipe’&amp;gt;: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;However this is clearly infeasible considering the number of call sites where we have to apply this logic. Thus, in order to maximize how concise the call site is, we can pull out this logic into a common helper function:&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;&amp;lt;%=localized(“report_summary.page_header”)&amp;gt;: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;&amp;lt;%=localized(“report_summary.team_label”)&amp;gt;: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;Here the assumption is that the localized(“key”) is aware of the currently selected language and that “report_summary.page_header” is the key for the header which is available in English and Hindi. The helper intelligently selects and returns the right text based on the currently selected language. Through this approach, we are able to render the view in multiple possible languages without any significant increase in the verbosity of the view.&lt;br /&gt;
&lt;br /&gt;
What’s more, is that the above problem is a common problem for user-facing applications and a standard library for doing the above and much more already exists for rails applications called i18n&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''''I18n - Internationalisation, How are we using I18n in Ruby on Rail'''''&amp;lt;br&amp;gt;&lt;br /&gt;
I18n is a ruby library/gem which helps us render the static string on the view dynamically. Dynamicity means that based on a local decision of choosing the current language of the view, the library returns the strings of that particular language at runtime.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
These strings, instead of hardcoding in the view.rb, are provided in external .yml files. Now at the View level, we can pass an id to the 't' function and the I18n library returns the string for that id of the current set language(called as locale). &lt;br /&gt;
[[File:i18n.png]]&lt;br /&gt;
For this purpose, we have to provide .yml files for each language and in those language-specific .yml, we have to provide a map of key-value pairs where the key is the id of the string and value is the string in that particular language. By default the language or locale is set to be English(:en). &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
THE GREATEST BENEFITS of using this library are - &amp;lt;br&amp;gt;&lt;br /&gt;
*The strings aren't hardcoded in the code/build. The strings are being fetched from external files which can be easily modified. For example, if one needs to change the text from 'Please Help' to 'Help', then one just needs to make a change in the .yml file and the change would reflect on the browser. For this change, we didn't need to redeploy the server. We just Decoupled the view when and where from what content is to be shown. &lt;br /&gt;
*Adding more languages is now super easy. Adding support for another language is just one line change in the config and adding a .yml file (having all the key-value pairs for the strings) for the new language. By doing this we can extend the language support as much as we want.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''''3. Translation gaps'''''&lt;br /&gt;
&amp;lt;br&amp;gt;Also, if the language is set to be Hindi or any other language but the key-value pair is not set for that particular string then, automatically the library returns the default which is the English text.&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;config.i18n.fallbacks = [:en]&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Alternate approaches ==&lt;br /&gt;
&lt;br /&gt;
'''1. Why not simply swap out the entire view for another language instead of each text?'''&amp;lt;br&amp;gt;&lt;br /&gt;
A view is an organized collection of multiple separate elements, views often involve dynamic generation and some level of sophistication. If we were to swap out one page in its entirety for another page this would often violate the '''DRY''' principle since we would have to have two separate implementations of the view in each language. Thus in the worst case, you have a complex view that has to be replicated dozens of times in various languages.&lt;br /&gt;
The majority of complexity of the page is not in the content itself but rather the code that executes to generate that content, thus it makes sense to instead maintain a single view and embed the language switching logic at each location where translation needs to occur to avoid replication of everything around it.&lt;br /&gt;
&lt;br /&gt;
'''2. Why did we pick i18n over implementing it ourselves?'''&amp;lt;br&amp;gt;&lt;br /&gt;
@ajulka&lt;br /&gt;
&lt;br /&gt;
'''3, Do we store the language preference, in the session or in the database?'''&amp;lt;br&amp;gt;&lt;br /&gt;
@rsabu&lt;br /&gt;
&lt;br /&gt;
== Use Case Diagram ==&lt;br /&gt;
== Major design patterns and principles used ==&lt;br /&gt;
&lt;br /&gt;
'''1. DRY: The i18n ‘t’ function'''&amp;lt;br&amp;gt;&lt;br /&gt;
We observe an extreme case of DRY with the t function of i18n.&lt;br /&gt;
For some background, the t function of the library takes in a key representing a text and returns the content referred to by that key in the preferred language of the user. It also performs many other functions such as falling back to a backup language if the translation for the preferred language has not been configured for that specific key. Thus since this logic has to be applied at every element of the view, it would behove us to extract this logic into a reusable function which is what the designers of the i18n library have employed&lt;br /&gt;
&lt;br /&gt;
'''2. Chain of responsibility'''&amp;lt;br&amp;gt;&lt;br /&gt;
@ajulka&lt;br /&gt;
&lt;br /&gt;
'''3. Open closed principle &amp;amp; Strategy Pattern'''&amp;lt;br&amp;gt;&lt;br /&gt;
As discussed in the “Language selection&amp;quot; design proposal above, if the user has not selected a preferred language, we do not simply default the view to render in the application language (English). Instead, the project requirements state that for course specific screens such as the assignment view, we would need to render the view in the course’s language.&lt;br /&gt;
While we could implement this code into the application controller that checks the controller being access and accordingly applies overrides on the default language, this violates the open closed principle since we would need to extend this logic any time we introduce a new course specific screen. Instead a better approach is to delegate the decision of selecting the language to the view itself since the view would be most aware of whether the view is course specific or not. We can also preserve the DRYness through mix-ins.&lt;br /&gt;
&lt;br /&gt;
== Database Design ==&lt;br /&gt;
Database Modification ==&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
Test Details&lt;br /&gt;
Manual Testing&lt;br /&gt;
Scenario 1&lt;br /&gt;
Scenario 2&lt;br /&gt;
Scenario 3&lt;br /&gt;
Scenario 4&lt;br /&gt;
Scenario 5&lt;br /&gt;
== Future Scope==&lt;br /&gt;
'''1. Expand to more languages'''&amp;lt;br&amp;gt;&lt;br /&gt;
As part of this project we have targetted Hindi as a second language, however our work makes it easy to extend to other languages as well.&lt;br /&gt;
&lt;br /&gt;
'''2. Identify and implement the course language override on more course specific screens'''&amp;lt;br&amp;gt;&lt;br /&gt;
As part of this project, we have introduced a generic framework by which any view can provide a preferred language in which it should be rendered, this is required by this project for the course language feature set by the instructor.&lt;br /&gt;
We have currently made the assignment screen display in the course’s language, however other screens such as the “Your work” screen and so on are also specific to the course could also be rendered in the course language when the user has not provided a preference.&lt;br /&gt;
&lt;br /&gt;
== Team ==&lt;br /&gt;
&lt;br /&gt;
'''Team Members'''&lt;br /&gt;
&lt;br /&gt;
Reuben M. V. John [[mailto:rmjohn2@ncsu.edu rmjohn2@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Renji Joseph Sabu [[mailto:rsabu@ncsu.edu rsabu@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Ashwin Das [[mailto:adas9@ncsu.edu adas9@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Arnav Julka [[mailto:ajulka@ncsu.edu ajulka@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Mentor'''&lt;br /&gt;
&lt;br /&gt;
Jialin Cui [[mailto:jcui9@ncsu.edu jcui9@ncsu.edu]]&lt;/div&gt;</summary>
		<author><name>Ajulka</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:I18n.png&amp;diff=140526</id>
		<title>File:I18n.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:I18n.png&amp;diff=140526"/>
		<updated>2021-11-03T01:38:55Z</updated>

		<summary type="html">&lt;p&gt;Ajulka: Ajulka uploaded a new version of File:I18n.png&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Ajulka</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization&amp;diff=140524</id>
		<title>CSC/ECE 517 Fall 2021 - E2159. Expertiza internationalization</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization&amp;diff=140524"/>
		<updated>2021-11-03T01:38:05Z</updated>

		<summary type="html">&lt;p&gt;Ajulka: /* Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction - Purpose &amp;amp; Problem ==&lt;br /&gt;
&lt;br /&gt;
Currently, all Expertiza screens can only be viewed in English. Many Expertiza users are from other countries. This is a problem since this limits the accessibility of Expertiza. An important step in solving this problem is by making Expertiza available in more languages, which is a form of internationalization.&lt;br /&gt;
W3C defines [https://www.w3.org/International/questions/qa-i18n internationalization] as “''the design and development of a product, application or document content that enables easy localization for target audiences that vary in culture, region, or language.''”&lt;br /&gt;
&lt;br /&gt;
[[File:country_pie.png]]&amp;lt;br&amp;gt;&lt;br /&gt;
Fig: Survey of home country of Expertiza users for a given course&lt;br /&gt;
&lt;br /&gt;
Breaking down internationalization into 3 sequential subproblems:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Scope:''' The scope of this project is limited however only to static strings. i.e. user-generated content will not be automatically translated to other languages.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''1. Language selection'''&lt;br /&gt;
&lt;br /&gt;
'''2. Rendering the language'''&amp;lt;br&amp;gt;&lt;br /&gt;
'''How do we go about rendering the screen in that language?''' &amp;lt;br&amp;gt;&lt;br /&gt;
In the previous step, we’ve identified the language in which a view is to be rendered. It is important to note that this language may not only differ for a different user, but also for a different page for the same user. The question now becomes, how do we render the screen in this language? To tackle this question, we explore 2 fundamental concepts:&amp;lt;br&amp;gt;&lt;br /&gt;
'''Views are composed of independent language elements'''&amp;lt;br&amp;gt;&lt;br /&gt;
While this is something we typically take for granted, it becomes especially important in the context of translation. That is, a view is not a single contiguous block of text, nor is it an atomic visualization of information (unlike a screenshot), but rather a carefully organized collection of individual elements such as texts, buttons, etc that each contain language that needs to be translated separately. Crucially, this means that we cannot swap out a page in one language in its entirety for a page in another language in its entirety. Instead, each individual element needs to be swapped out individually so as to only impact the language and not the structural composition of the page itself.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''*Views require translation at a large number of call sites'''&amp;lt;br&amp;gt;&lt;br /&gt;
Given that a view is composed of individual elements, this also means that the computation of how to translate such an element such as a button’s text would need to be done separately for each element. This would result in not only a single centralized &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''3. Translation gaps'''&lt;br /&gt;
&lt;br /&gt;
== Scope ==&lt;br /&gt;
== Design ==&lt;br /&gt;
Proposed Solution&lt;br /&gt;
1. Language selection&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
'''''2. Rendering the language'''''&amp;lt;br&amp;gt;&lt;br /&gt;
Rendering the language&amp;lt;br&amp;gt;&lt;br /&gt;
Once we have determined the language in which to render the page, we now need to update the rails view code to actually generate the appropriate HTML in the target language. This is the responsibility of the view. However, currently, the actual content of the HTML is hardcoded in (red) English. For example:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;Summary Report for assignment: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;Team: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
As discussed earlier, “Views are composed of independent language elements” and so we cannot simply swap out the entire page content for a separate page in another language (Why? - See “swap out the entire view” in the alternative approaches section):&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;Rapport de synthèse pour l'affectation: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;Équipe: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;Instead, the better approach is to have a single unified view that dynamically changes based on the selected language:&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;&amp;lt;%=language==’en’ ? ‘Summary Report for assignment’ : ‘Rapport de synthèse pour l'affectation’&amp;gt;: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;&amp;lt;%=language==’en’ ? ‘Team’ : ‘Équipe’&amp;gt;: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;However this is clearly infeasible considering the number of call sites where we have to apply this logic. Thus, in order to maximize how concise the call site is, we can pull out this logic into a common helper function:&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;&amp;lt;%=localized(“report_summary.page_header”)&amp;gt;: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;&amp;lt;%=localized(“report_summary.team_label”)&amp;gt;: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;Here the assumption is that the localized(“key”) is aware of the currently selected language and that “report_summary.page_header” is the key for the header which is available in English and Hindi. The helper intelligently selects and returns the right text based on the currently selected language. Through this approach, we are able to render the view in multiple possible languages without any significant increase in the verbosity of the view.&lt;br /&gt;
&lt;br /&gt;
What’s more, is that the above problem is a common problem for user-facing applications and a standard library for doing the above and much more already exists for rails applications called i18n&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''''I18n - Internationalisation, How are we using I18n in Ruby on Rail'''''&amp;lt;br&amp;gt;&lt;br /&gt;
I18n is a ruby library/gem which helps us render the static string on the view dynamically. Dynamicity means that based on a local decision of choosing the current language of the view, the library returns the strings of that particular language at runtime.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
These strings, instead of hardcoding in the view.rb, are provided in external .yml files. Now at the View level, we can pass an id to the 't' function and the I18n library returns the string for that id of the current set language(called as locale). &lt;br /&gt;
[[File:i18n]]&lt;br /&gt;
For this purpose, we have to provide .yml files for each language and in those language-specific .yml, we have to provide a map of key-value pairs where the key is the id of the string and value is the string in that particular language. By default the language or locale is set to be English(:en). &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
THE GREATEST BENEFITS of using this library are - &amp;lt;br&amp;gt;&lt;br /&gt;
*The strings aren't hardcoded in the code/build. The strings are being fetched from external files which can be easily modified. For example, if one needs to change the text from 'Please Help' to 'Help', then one just needs to make a change in the .yml file and the change would reflect on the browser. For this change, we didn't need to redeploy the server. We just Decoupled the view when and where from what content is to be shown. &lt;br /&gt;
*Adding more languages is now super easy. Adding support for another language is just one line change in the config and adding a .yml file (having all the key-value pairs for the strings) for the new language. By doing this we can extend the language support as much as we want.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''''3. Translation gaps'''''&lt;br /&gt;
&amp;lt;br&amp;gt;Also, if the language is set to be Hindi or any other language but the key-value pair is not set for that particular string then, automatically the library returns the default which is the English text.&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;config.i18n.fallbacks = [:en]&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Alternate approaches ==&lt;br /&gt;
&lt;br /&gt;
'''1. Why not simply swap out the entire view for another language instead of each text?'''&amp;lt;br&amp;gt;&lt;br /&gt;
A view is an organized collection of multiple separate elements, views often involve dynamic generation and some level of sophistication. If we were to swap out one page in its entirety for another page this would often violate the '''DRY''' principle since we would have to have two separate implementations of the view in each language. Thus in the worst case, you have a complex view that has to be replicated dozens of times in various languages.&lt;br /&gt;
The majority of complexity of the page is not in the content itself but rather the code that executes to generate that content, thus it makes sense to instead maintain a single view and embed the language switching logic at each location where translation needs to occur to avoid replication of everything around it.&lt;br /&gt;
&lt;br /&gt;
'''2. Why did we pick i18n over implementing it ourselves?'''&amp;lt;br&amp;gt;&lt;br /&gt;
@ajulka&lt;br /&gt;
&lt;br /&gt;
'''3, Do we store the language preference, in the session or in the database?'''&amp;lt;br&amp;gt;&lt;br /&gt;
@rsabu&lt;br /&gt;
&lt;br /&gt;
== Use Case Diagram ==&lt;br /&gt;
== Major design patterns and principles used ==&lt;br /&gt;
&lt;br /&gt;
'''1. DRY: The i18n ‘t’ function'''&amp;lt;br&amp;gt;&lt;br /&gt;
We observe an extreme case of DRY with the t function of i18n.&lt;br /&gt;
For some background, the t function of the library takes in a key representing a text and returns the content referred to by that key in the preferred language of the user. It also performs many other functions such as falling back to a backup language if the translation for the preferred language has not been configured for that specific key. Thus since this logic has to be applied at every element of the view, it would behove us to extract this logic into a reusable function which is what the designers of the i18n library have employed&lt;br /&gt;
&lt;br /&gt;
'''2. Chain of responsibility'''&amp;lt;br&amp;gt;&lt;br /&gt;
@ajulka&lt;br /&gt;
&lt;br /&gt;
'''3. Open closed principle &amp;amp; Strategy Pattern'''&amp;lt;br&amp;gt;&lt;br /&gt;
As discussed in the “Language selection&amp;quot; design proposal above, if the user has not selected a preferred language, we do not simply default the view to render in the application language (English). Instead, the project requirements state that for course specific screens such as the assignment view, we would need to render the view in the course’s language.&lt;br /&gt;
While we could implement this code into the application controller that checks the controller being access and accordingly applies overrides on the default language, this violates the open closed principle since we would need to extend this logic any time we introduce a new course specific screen. Instead a better approach is to delegate the decision of selecting the language to the view itself since the view would be most aware of whether the view is course specific or not. We can also preserve the DRYness through mix-ins.&lt;br /&gt;
&lt;br /&gt;
== Database Design ==&lt;br /&gt;
Database Modification ==&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
Test Details&lt;br /&gt;
Manual Testing&lt;br /&gt;
Scenario 1&lt;br /&gt;
Scenario 2&lt;br /&gt;
Scenario 3&lt;br /&gt;
Scenario 4&lt;br /&gt;
Scenario 5&lt;br /&gt;
== Future Scope==&lt;br /&gt;
'''1. Expand to more languages'''&amp;lt;br&amp;gt;&lt;br /&gt;
As part of this project we have targetted Hindi as a second language, however our work makes it easy to extend to other languages as well.&lt;br /&gt;
&lt;br /&gt;
'''2. Identify and implement the course language override on more course specific screens'''&amp;lt;br&amp;gt;&lt;br /&gt;
As part of this project, we have introduced a generic framework by which any view can provide a preferred language in which it should be rendered, this is required by this project for the course language feature set by the instructor.&lt;br /&gt;
We have currently made the assignment screen display in the course’s language, however other screens such as the “Your work” screen and so on are also specific to the course could also be rendered in the course language when the user has not provided a preference.&lt;br /&gt;
&lt;br /&gt;
== Team ==&lt;br /&gt;
&lt;br /&gt;
'''Team Members'''&lt;br /&gt;
&lt;br /&gt;
Reuben M. V. John [[mailto:rmjohn2@ncsu.edu rmjohn2@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Renji Joseph Sabu [[mailto:rsabu@ncsu.edu rsabu@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Ashwin Das [[mailto:adas9@ncsu.edu adas9@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Arnav Julka [[mailto:ajulka@ncsu.edu ajulka@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Mentor'''&lt;br /&gt;
&lt;br /&gt;
Jialin Cui [[mailto:jcui9@ncsu.edu jcui9@ncsu.edu]]&lt;/div&gt;</summary>
		<author><name>Ajulka</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:I18n.png&amp;diff=140523</id>
		<title>File:I18n.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:I18n.png&amp;diff=140523"/>
		<updated>2021-11-03T01:37:26Z</updated>

		<summary type="html">&lt;p&gt;Ajulka: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Ajulka</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization&amp;diff=140519</id>
		<title>CSC/ECE 517 Fall 2021 - E2159. Expertiza internationalization</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization&amp;diff=140519"/>
		<updated>2021-11-03T01:29:00Z</updated>

		<summary type="html">&lt;p&gt;Ajulka: /* Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction - Purpose &amp;amp; Problem ==&lt;br /&gt;
1. Language selection&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
'''''2 Rendering the language'''''&amp;lt;br&amp;gt;&lt;br /&gt;
'''How do we go about rendering the screen in that language?''' &amp;lt;br&amp;gt;&lt;br /&gt;
In the previous step, we’ve identified the language in which a view is to be rendered. It is important to note that this language may not only differ for a different user, but also for a different page for the same user. The question now becomes, how do we render the screen in this language? To tackle this question, we explore 2 fundamental concepts:&amp;lt;br&amp;gt;&lt;br /&gt;
'''Views are composed of independent language elements'''&amp;lt;br&amp;gt;&lt;br /&gt;
While this is something we typically take for granted, it becomes especially important in the context of translation. That is, a view is not a single contiguous block of text, nor is it an atomic visualization of information (unlike a screenshot), but rather a carefully organized collection of individual elements such as texts, buttons, etc that each contain language that needs to be translated separately. Crucially, this means that we cannot swap out a page in one language in its entirety for a page in another language in its entirety. Instead, each individual element needs to be swapped out individually so as to only impact the language and not the structural composition of the page itself.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''*Views require translation at a large number of call sites'''&amp;lt;br&amp;gt;&lt;br /&gt;
Given that a view is composed of individual elements, this also means that the computation of how to translate such an element such as a button’s text would need to be done separately for each element. This would result in not only a single centralized &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Translation gaps&lt;br /&gt;
&lt;br /&gt;
== Scope ==&lt;br /&gt;
== Design ==&lt;br /&gt;
Proposed Solution&lt;br /&gt;
1. Language selection&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
'''''2. Rendering the language'''''&amp;lt;br&amp;gt;&lt;br /&gt;
Rendering the language&amp;lt;br&amp;gt;&lt;br /&gt;
Once we have determined the language in which to render the page, we now need to update the rails view code to actually generate the appropriate HTML in the target language. This is the responsibility of the view. However, currently, the actual content of the HTML is hardcoded in (red) English. For example:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;Summary Report for assignment: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;Team: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
As discussed earlier, “Views are composed of independent language elements” and so we cannot simply swap out the entire page content for a separate page in another language (Why? - See “swap out the entire view” in the alternative approaches section):&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;Rapport de synthèse pour l'affectation: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;Équipe: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;Instead, the better approach is to have a single unified view that dynamically changes based on the selected language:&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;&amp;lt;%=language==’en’ ? ‘Summary Report for assignment’ : ‘Rapport de synthèse pour l'affectation’&amp;gt;: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;&amp;lt;%=language==’en’ ? ‘Team’ : ‘Équipe’&amp;gt;: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;However this is clearly infeasible considering the number of call sites where we have to apply this logic. Thus, in order to maximize how concise the call site is, we can pull out this logic into a common helper function:&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;&amp;lt;%=localized(“report_summary.page_header”)&amp;gt;: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;&amp;lt;%=localized(“report_summary.team_label”)&amp;gt;: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;Here the assumption is that the localized(“key”) is aware of the currently selected language and that “report_summary.page_header” is the key for the header which is available in English and Hindi. The helper intelligently selects and returns the right text based on the currently selected language. Through this approach, we are able to render the view in multiple possible languages without any significant increase in the verbosity of the view.&lt;br /&gt;
&lt;br /&gt;
What’s more, is that the above problem is a common problem for user-facing applications and a standard library for doing the above and much more already exists for rails applications called i18n&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''''I18n - Internationalisation, How are we using I18n in Ruby on Rail'''''&amp;lt;br&amp;gt;&lt;br /&gt;
I18n is a ruby library/gem which helps us render the static string on the view dynamically. Dynamicity means that based on a local decision of choosing the current language of the view, the library returns the strings of that particular language at runtime.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
These strings, instead of hardcoding in the view.rb, are provided in external .yml files. Now at the View level, we can pass an id to the 't' function and the I18n library returns the string for that id of the current set language(called as locale). &lt;br /&gt;
[[File:Example.jpg]]&lt;br /&gt;
For this purpose, we have to provide .yml files for each language and in those language-specific .yml, we have to provide a map of key-value pairs where the key is the id of the string and value is the string in that particular language. By default the language or locale is set to be English(:en). &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
THE GREATEST BENEFITS of using this library are - &amp;lt;br&amp;gt;&lt;br /&gt;
*The strings aren't hardcoded in the code/build. The strings are being fetched from external files which can be easily modified. For example, if one needs to change the text from 'Please Help' to 'Help', then one just needs to make a change in the .yml file and the change would reflect on the browser. For this change, we didn't need to redeploy the server. We just Decoupled the view when and where from what content is to be shown. &lt;br /&gt;
*Adding more languages is now super easy. Adding support for another language is just one line change in the config and adding a .yml file (having all the key-value pairs for the strings) for the new language. By doing this we can extend the language support as much as we want.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''''3. Translation gaps'''''&lt;br /&gt;
&amp;lt;br&amp;gt;Also, if the language is set to be Hindi or any other language but the key-value pair is not set for that particular string then, automatically the library returns the default which is the English text.&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;config.i18n.fallbacks = [:en]&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Alternate approaches ==&lt;br /&gt;
&lt;br /&gt;
'''1. Why not simply swap out the entire view for another language instead of each text?'''&amp;lt;br&amp;gt;&lt;br /&gt;
A view is an organized collection of multiple separate elements, views often involve dynamic generation and some level of sophistication. If we were to swap out one page in its entirety for another page this would often violate the '''DRY''' principle since we would have to have two separate implementations of the view in each language. Thus in the worst case, you have a complex view that has to be replicated dozens of times in various languages.&lt;br /&gt;
The majority of complexity of the page is not in the content itself but rather the code that executes to generate that content, thus it makes sense to instead maintain a single view and embed the language switching logic at each location where translation needs to occur to avoid replication of everything around it.&lt;br /&gt;
&lt;br /&gt;
'''2. Why did we pick i18n over implementing it ourselves?'''&amp;lt;br&amp;gt;&lt;br /&gt;
@ajulka&lt;br /&gt;
&lt;br /&gt;
'''3, Do we store the language preference, in the session or in the database?'''&amp;lt;br&amp;gt;&lt;br /&gt;
@rsabu&lt;br /&gt;
&lt;br /&gt;
== Use Case Diagram ==&lt;br /&gt;
== Major design patterns and principles used ==&lt;br /&gt;
&lt;br /&gt;
'''1. DRY: The i18n ‘t’ function'''&amp;lt;br&amp;gt;&lt;br /&gt;
We observe an extreme case of DRY with the t function of i18n.&lt;br /&gt;
For some background, the t function of the library takes in a key representing a text and returns the content referred to by that key in the preferred language of the user. It also performs many other functions such as falling back to a backup language if the translation for the preferred language has not been configured for that specific key. Thus since this logic has to be applied at every element of the view, it would behove us to extract this logic into a reusable function which is what the designers of the i18n library have employed&lt;br /&gt;
&lt;br /&gt;
'''2. Chain of responsibility'''&amp;lt;br&amp;gt;&lt;br /&gt;
@ajulka&lt;br /&gt;
&lt;br /&gt;
'''3. Open closed principle &amp;amp; Strategy Pattern'''&amp;lt;br&amp;gt;&lt;br /&gt;
As discussed in the “Language selection&amp;quot; design proposal above, if the user has not selected a preferred language, we do not simply default the view to render in the application language (English). Instead, the project requirements state that for course specific screens such as the assignment view, we would need to render the view in the course’s language.&lt;br /&gt;
While we could implement this code into the application controller that checks the controller being access and accordingly applies overrides on the default language, this violates the open closed principle since we would need to extend this logic any time we introduce a new course specific screen. Instead a better approach is to delegate the decision of selecting the language to the view itself since the view would be most aware of whether the view is course specific or not. We can also preserve the DRYness through mix-ins.&lt;br /&gt;
&lt;br /&gt;
== Database Design ==&lt;br /&gt;
Database Modification ==&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
Test Details&lt;br /&gt;
Manual Testing&lt;br /&gt;
Scenario 1&lt;br /&gt;
Scenario 2&lt;br /&gt;
Scenario 3&lt;br /&gt;
Scenario 4&lt;br /&gt;
Scenario 5&lt;br /&gt;
== Future Scope==&lt;br /&gt;
'''1. Expand to more languages'''&amp;lt;br&amp;gt;&lt;br /&gt;
As part of this project we have targetted Hindi as a second language, however our work makes it easy to extend to other languages as well.&lt;br /&gt;
&lt;br /&gt;
'''2. Identify and implement the course language override on more course specific screens'''&amp;lt;br&amp;gt;&lt;br /&gt;
As part of this project, we have introduced a generic framework by which any view can provide a preferred language in which it should be rendered, this is required by this project for the course language feature set by the instructor.&lt;br /&gt;
We have currently made the assignment screen display in the course’s language, however other screens such as the “Your work” screen and so on are also specific to the course could also be rendered in the course language when the user has not provided a preference.&lt;br /&gt;
&lt;br /&gt;
== Team ==&lt;br /&gt;
&lt;br /&gt;
'''Team Members'''&lt;br /&gt;
&lt;br /&gt;
Reuben M. V. John [[mailto:rmjohn2@ncsu.edu rmjohn2@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Renji Joseph Sabu [[mailto:rsabu@ncsu.edu rsabu@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Ashwin Das [[mailto:adas9@ncsu.edu adas9@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Arnav Julka [[mailto:ajulka@ncsu.edu ajulka@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Mentor'''&lt;br /&gt;
&lt;br /&gt;
Jialin Cui [[mailto:jcui9@ncsu.edu jcui9@ncsu.edu]]&lt;/div&gt;</summary>
		<author><name>Ajulka</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization&amp;diff=140518</id>
		<title>CSC/ECE 517 Fall 2021 - E2159. Expertiza internationalization</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization&amp;diff=140518"/>
		<updated>2021-11-03T01:28:02Z</updated>

		<summary type="html">&lt;p&gt;Ajulka: /* Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction - Purpose &amp;amp; Problem ==&lt;br /&gt;
1. Language selection&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
'''''2 Rendering the language'''''&amp;lt;br&amp;gt;&lt;br /&gt;
'''How do we go about rendering the screen in that language?''' &amp;lt;br&amp;gt;&lt;br /&gt;
In the previous step, we’ve identified the language in which a view is to be rendered. It is important to note that this language may not only differ for a different user, but also for a different page for the same user. The question now becomes, how do we render the screen in this language? To tackle this question, we explore 2 fundamental concepts:&amp;lt;br&amp;gt;&lt;br /&gt;
'''Views are composed of independent language elements'''&amp;lt;br&amp;gt;&lt;br /&gt;
While this is something we typically take for granted, it becomes especially important in the context of translation. That is, a view is not a single contiguous block of text, nor is it an atomic visualization of information (unlike a screenshot), but rather a carefully organized collection of individual elements such as texts, buttons, etc that each contain language that needs to be translated separately. Crucially, this means that we cannot swap out a page in one language in its entirety for a page in another language in its entirety. Instead, each individual element needs to be swapped out individually so as to only impact the language and not the structural composition of the page itself.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''*Views require translation at a large number of call sites'''&amp;lt;br&amp;gt;&lt;br /&gt;
Given that a view is composed of individual elements, this also means that the computation of how to translate such an element such as a button’s text would need to be done separately for each element. This would result in not only a single centralized &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Translation gaps&lt;br /&gt;
&lt;br /&gt;
== Scope ==&lt;br /&gt;
== Design ==&lt;br /&gt;
Proposed Solution&lt;br /&gt;
1. Language selection&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
'''''2. Rendering the language'''''&amp;lt;br&amp;gt;&lt;br /&gt;
Rendering the language&amp;lt;br&amp;gt;&lt;br /&gt;
Once we have determined the language in which to render the page, we now need to update the rails view code to actually generate the appropriate HTML in the target language. This is the responsibility of the view. However, currently, the actual content of the HTML is hardcoded in (red) English. For example:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;Summary Report for assignment: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;Team: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
As discussed earlier, “Views are composed of independent language elements” and so we cannot simply swap out the entire page content for a separate page in another language (Why? - See “swap out the entire view” in the alternative approaches section):&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;Rapport de synthèse pour l'affectation: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;Équipe: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;Instead, the better approach is to have a single unified view that dynamically changes based on the selected language:&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;&amp;lt;%=language==’en’ ? ‘Summary Report for assignment’ : ‘Rapport de synthèse pour l'affectation’&amp;gt;: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;&amp;lt;%=language==’en’ ? ‘Team’ : ‘Équipe’&amp;gt;: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;However this is clearly infeasible considering the number of call sites where we have to apply this logic. Thus, in order to maximize how concise the call site is, we can pull out this logic into a common helper function:&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;&amp;lt;%=localized(“report_summary.page_header”)&amp;gt;: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;&amp;lt;%=localized(“report_summary.team_label”)&amp;gt;: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;Here the assumption is that the localized(“key”) is aware of the currently selected language and that “report_summary.page_header” is the key for the header which is available in English and Hindi. The helper intelligently selects and returns the right text based on the currently selected language. Through this approach, we are able to render the view in multiple possible languages without any significant increase in the verbosity of the view.&lt;br /&gt;
&lt;br /&gt;
What’s more, is that the above problem is a common problem for user-facing applications and a standard library for doing the above and much more already exists for rails applications called i18n&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''''I18n - Internationalisation, How are we using I18n in Ruby on Rail'''''&amp;lt;br&amp;gt;&lt;br /&gt;
I18n is a ruby library/gem which helps us render the static string on the view dynamically. Dynamicity means that based on a local decision of choosing the current language of the view, the library returns the strings of that particular language at runtime.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
These strings, instead of hardcoding in the view.rb, are provided in external .yml files. Now at the View level, we can pass an id to the 't' function and the I18n library returns the string for that id of the current set language(called as locale). &lt;br /&gt;
&lt;br /&gt;
For this purpose, we have to provide .yml files for each language and in those language-specific .yml, we have to provide a map of key-value pairs where the key is the id of the string and value is the string in that particular language. By default the language or locale is set to be English(:en). &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
THE GREATEST BENEFITS of using this library are - &amp;lt;br&amp;gt;&lt;br /&gt;
*The strings aren't hardcoded in the code/build. The strings are being fetched from external files which can be easily modified. For example, if one needs to change the text from 'Please Help' to 'Help', then one just needs to make a change in the .yml file and the change would reflect on the browser. For this change, we didn't need to redeploy the server. We just Decoupled the view when and where from what content is to be shown. &lt;br /&gt;
*Adding more languages is now super easy. Adding support for another language is just one line change in the config and adding a .yml file (having all the key-value pairs for the strings) for the new language. By doing this we can extend the language support as much as we want.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''''3. Translation gaps'''''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;Also, if the language is set to be Hindi or any other language but the key-value pair is not set for that particular string then, automatically the library returns the default which is the English text.&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;config.i18n.fallbacks = [:en]&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Alternate approaches ==&lt;br /&gt;
&lt;br /&gt;
'''1. Why not simply swap out the entire view for another language instead of each text?'''&amp;lt;br&amp;gt;&lt;br /&gt;
A view is an organized collection of multiple separate elements, views often involve dynamic generation and some level of sophistication. If we were to swap out one page in its entirety for another page this would often violate the '''DRY''' principle since we would have to have two separate implementations of the view in each language. Thus in the worst case, you have a complex view that has to be replicated dozens of times in various languages.&lt;br /&gt;
The majority of complexity of the page is not in the content itself but rather the code that executes to generate that content, thus it makes sense to instead maintain a single view and embed the language switching logic at each location where translation needs to occur to avoid replication of everything around it.&lt;br /&gt;
&lt;br /&gt;
'''2. Why did we pick i18n over implementing it ourselves?'''&amp;lt;br&amp;gt;&lt;br /&gt;
@ajulka&lt;br /&gt;
&lt;br /&gt;
'''3, Do we store the language preference, in the session or in the database?'''&amp;lt;br&amp;gt;&lt;br /&gt;
@rsabu&lt;br /&gt;
&lt;br /&gt;
== Use Case Diagram ==&lt;br /&gt;
== Major design patterns and principles used ==&lt;br /&gt;
&lt;br /&gt;
'''1. DRY: The i18n ‘t’ function'''&amp;lt;br&amp;gt;&lt;br /&gt;
We observe an extreme case of DRY with the t function of i18n.&lt;br /&gt;
For some background, the t function of the library takes in a key representing a text and returns the content referred to by that key in the preferred language of the user. It also performs many other functions such as falling back to a backup language if the translation for the preferred language has not been configured for that specific key. Thus since this logic has to be applied at every element of the view, it would behove us to extract this logic into a reusable function which is what the designers of the i18n library have employed&lt;br /&gt;
&lt;br /&gt;
'''2. Chain of responsibility'''&amp;lt;br&amp;gt;&lt;br /&gt;
@ajulka&lt;br /&gt;
&lt;br /&gt;
'''3. Open closed principle &amp;amp; Strategy Pattern'''&amp;lt;br&amp;gt;&lt;br /&gt;
As discussed in the “Language selection&amp;quot; design proposal above, if the user has not selected a preferred language, we do not simply default the view to render in the application language (English). Instead, the project requirements state that for course specific screens such as the assignment view, we would need to render the view in the course’s language.&lt;br /&gt;
While we could implement this code into the application controller that checks the controller being access and accordingly applies overrides on the default language, this violates the open closed principle since we would need to extend this logic any time we introduce a new course specific screen. Instead a better approach is to delegate the decision of selecting the language to the view itself since the view would be most aware of whether the view is course specific or not. We can also preserve the DRYness through mix-ins.&lt;br /&gt;
&lt;br /&gt;
== Database Design ==&lt;br /&gt;
Database Modification ==&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
Test Details&lt;br /&gt;
Manual Testing&lt;br /&gt;
Scenario 1&lt;br /&gt;
Scenario 2&lt;br /&gt;
Scenario 3&lt;br /&gt;
Scenario 4&lt;br /&gt;
Scenario 5&lt;br /&gt;
== Future Scope==&lt;br /&gt;
'''1. Expand to more languages'''&amp;lt;br&amp;gt;&lt;br /&gt;
As part of this project we have targetted Hindi as a second language, however our work makes it easy to extend to other languages as well.&lt;br /&gt;
&lt;br /&gt;
'''2. Identify and implement the course language override on more course specific screens'''&amp;lt;br&amp;gt;&lt;br /&gt;
As part of this project, we have introduced a generic framework by which any view can provide a preferred language in which it should be rendered, this is required by this project for the course language feature set by the instructor.&lt;br /&gt;
We have currently made the assignment screen display in the course’s language, however other screens such as the “Your work” screen and so on are also specific to the course could also be rendered in the course language when the user has not provided a preference.&lt;br /&gt;
&lt;br /&gt;
== Team ==&lt;br /&gt;
&lt;br /&gt;
'''Team Members'''&lt;br /&gt;
&lt;br /&gt;
Reuben M. V. John [[mailto:rmjohn2@ncsu.edu rmjohn2@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Renji Joseph Sabu [[mailto:rsabu@ncsu.edu rsabu@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Ashwin Das [[mailto:adas9@ncsu.edu adas9@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Arnav Julka [[mailto:ajulka@ncsu.edu ajulka@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Mentor'''&lt;br /&gt;
&lt;br /&gt;
Jialin Cui [[mailto:jcui9@ncsu.edu jcui9@ncsu.edu]]&lt;/div&gt;</summary>
		<author><name>Ajulka</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization&amp;diff=140517</id>
		<title>CSC/ECE 517 Fall 2021 - E2159. Expertiza internationalization</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization&amp;diff=140517"/>
		<updated>2021-11-03T01:26:07Z</updated>

		<summary type="html">&lt;p&gt;Ajulka: /* Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction - Purpose &amp;amp; Problem ==&lt;br /&gt;
1. Language selection&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
'''''2 Rendering the language'''''&amp;lt;br&amp;gt;&lt;br /&gt;
'''How do we go about rendering the screen in that language?''' &amp;lt;br&amp;gt;&lt;br /&gt;
In the previous step, we’ve identified the language in which a view is to be rendered. It is important to note that this language may not only differ for a different user, but also for a different page for the same user. The question now becomes, how do we render the screen in this language? To tackle this question, we explore 2 fundamental concepts:&amp;lt;br&amp;gt;&lt;br /&gt;
'''Views are composed of independent language elements'''&amp;lt;br&amp;gt;&lt;br /&gt;
While this is something we typically take for granted, it becomes especially important in the context of translation. That is, a view is not a single contiguous block of text, nor is it an atomic visualization of information (unlike a screenshot), but rather a carefully organized collection of individual elements such as texts, buttons, etc that each contain language that needs to be translated separately. Crucially, this means that we cannot swap out a page in one language in its entirety for a page in another language in its entirety. Instead, each individual element needs to be swapped out individually so as to only impact the language and not the structural composition of the page itself.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''*Views require translation at a large number of call sites'''&amp;lt;br&amp;gt;&lt;br /&gt;
Given that a view is composed of individual elements, this also means that the computation of how to translate such an element such as a button’s text would need to be done separately for each element. This would result in not only a single centralized &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Translation gaps&lt;br /&gt;
&lt;br /&gt;
== Scope ==&lt;br /&gt;
== Design ==&lt;br /&gt;
Proposed Solution&lt;br /&gt;
1. Language selection&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
'''''2. Rendering the language'''''&amp;lt;br&amp;gt;&lt;br /&gt;
Rendering the language&amp;lt;br&amp;gt;&lt;br /&gt;
Once we have determined the language in which to render the page, we now need to update the rails view code to actually generate the appropriate HTML in the target language. This is the responsibility of the view. However, currently, the actual content of the HTML is hardcoded in (red) English. For example:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;Summary Report for assignment: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;Team: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
As discussed earlier, “Views are composed of independent language elements” and so we cannot simply swap out the entire page content for a separate page in another language (Why? - See “swap out the entire view” in the alternative approaches section):&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;Rapport de synthèse pour l'affectation: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;Équipe: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;Instead, the better approach is to have a single unified view that dynamically changes based on the selected language:&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;&amp;lt;%=language==’en’ ? ‘Summary Report for assignment’ : ‘Rapport de synthèse pour l'affectation’&amp;gt;: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;&amp;lt;%=language==’en’ ? ‘Team’ : ‘Équipe’&amp;gt;: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;However this is clearly infeasible considering the number of call sites where we have to apply this logic. Thus, in order to maximize how concise the call site is, we can pull out this logic into a common helper function:&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;&amp;lt;%=localized(“report_summary.page_header”)&amp;gt;: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;&amp;lt;%=localized(“report_summary.team_label”)&amp;gt;: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;Here the assumption is that the localized(“key”) is aware of the currently selected language and that “report_summary.page_header” is the key for the header which is available in English and Hindi. The helper intelligently selects and returns the right text based on the currently selected language. Through this approach, we are able to render the view in multiple possible languages without any significant increase in the verbosity of the view.&lt;br /&gt;
&lt;br /&gt;
What’s more, is that the above problem is a common problem for user-facing applications and a standard library for doing the above and much more already exists for rails applications called i18n&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''''I18n - Internationalisation, How are we using I18n in Ruby on Rail'''''&amp;lt;br&amp;gt;&lt;br /&gt;
I18n is a ruby library/gem which helps us render the static string on the view dynamically. Dynamicity means that based on a local decision of choosing the current language of the view, the library returns the strings of that particular language at runtime.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
These strings, instead of hardcoding in the view.rb, are provided in external .yml files. Now at the View level, we can pass an id to the 't' function and the I18n library returns the string for that id of the current set language(called as locale). &lt;br /&gt;
&lt;br /&gt;
For this purpose, we have to provide .yml files for each language and in those language-specific .yml, we have to provide a map of key-value pairs where the key is the id of the string and value is the string in that particular language. By default the language or locale is set to be English(:en). &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
THE GREATEST BENEFITS of using this library are - &amp;lt;br&amp;gt;&lt;br /&gt;
*The strings aren't hardcoded in the code/build. The strings are being fetched from external files which can be easily modified. For example, if one needs to change the text from 'Please Help' to 'Help', then one just needs to make a change in the .yml file and the change would reflect on the browser. For this change, we didn't need to redeploy the server. We just Decoupled the view when and where from what content is to be shown. &lt;br /&gt;
*Adding more languages is now super easy. Adding support for another language is just one line change in the config and adding a .yml file (having all the key-value pairs for the strings) for the new language. By doing this we can extend the language support as much as we want.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Translation gaps&lt;br /&gt;
&lt;br /&gt;
== Alternate approaches ==&lt;br /&gt;
&lt;br /&gt;
'''1. Why not simply swap out the entire view for another language instead of each text?'''&amp;lt;br&amp;gt;&lt;br /&gt;
A view is an organized collection of multiple separate elements, views often involve dynamic generation and some level of sophistication. If we were to swap out one page in its entirety for another page this would often violate the '''DRY''' principle since we would have to have two separate implementations of the view in each language. Thus in the worst case, you have a complex view that has to be replicated dozens of times in various languages.&lt;br /&gt;
The majority of complexity of the page is not in the content itself but rather the code that executes to generate that content, thus it makes sense to instead maintain a single view and embed the language switching logic at each location where translation needs to occur to avoid replication of everything around it.&lt;br /&gt;
&lt;br /&gt;
'''2. Why did we pick i18n over implementing it ourselves?'''&amp;lt;br&amp;gt;&lt;br /&gt;
@ajulka&lt;br /&gt;
&lt;br /&gt;
'''3, Do we store the language preference, in the session or in the database?'''&amp;lt;br&amp;gt;&lt;br /&gt;
@rsabu&lt;br /&gt;
&lt;br /&gt;
== Use Case Diagram ==&lt;br /&gt;
== Major design patterns and principles used ==&lt;br /&gt;
&lt;br /&gt;
'''1. DRY: The i18n ‘t’ function'''&amp;lt;br&amp;gt;&lt;br /&gt;
We observe an extreme case of DRY with the t function of i18n.&lt;br /&gt;
For some background, the t function of the library takes in a key representing a text and returns the content referred to by that key in the preferred language of the user. It also performs many other functions such as falling back to a backup language if the translation for the preferred language has not been configured for that specific key. Thus since this logic has to be applied at every element of the view, it would behove us to extract this logic into a reusable function which is what the designers of the i18n library have employed&lt;br /&gt;
&lt;br /&gt;
'''2. Chain of responsibility'''&amp;lt;br&amp;gt;&lt;br /&gt;
@ajulka&lt;br /&gt;
&lt;br /&gt;
'''3. Open closed principle &amp;amp; Strategy Pattern'''&amp;lt;br&amp;gt;&lt;br /&gt;
As discussed in the “Language selection&amp;quot; design proposal above, if the user has not selected a preferred language, we do not simply default the view to render in the application language (English). Instead, the project requirements state that for course specific screens such as the assignment view, we would need to render the view in the course’s language.&lt;br /&gt;
While we could implement this code into the application controller that checks the controller being access and accordingly applies overrides on the default language, this violates the open closed principle since we would need to extend this logic any time we introduce a new course specific screen. Instead a better approach is to delegate the decision of selecting the language to the view itself since the view would be most aware of whether the view is course specific or not. We can also preserve the DRYness through mix-ins.&lt;br /&gt;
&lt;br /&gt;
== Database Design ==&lt;br /&gt;
Database Modification ==&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
Test Details&lt;br /&gt;
Manual Testing&lt;br /&gt;
Scenario 1&lt;br /&gt;
Scenario 2&lt;br /&gt;
Scenario 3&lt;br /&gt;
Scenario 4&lt;br /&gt;
Scenario 5&lt;br /&gt;
== Future Scope==&lt;br /&gt;
'''1. Expand to more languages'''&amp;lt;br&amp;gt;&lt;br /&gt;
As part of this project we have targetted Hindi as a second language, however our work makes it easy to extend to other languages as well.&lt;br /&gt;
&lt;br /&gt;
'''2. Identify and implement the course language override on more course specific screens'''&amp;lt;br&amp;gt;&lt;br /&gt;
As part of this project, we have introduced a generic framework by which any view can provide a preferred language in which it should be rendered, this is required by this project for the course language feature set by the instructor.&lt;br /&gt;
We have currently made the assignment screen display in the course’s language, however other screens such as the “Your work” screen and so on are also specific to the course could also be rendered in the course language when the user has not provided a preference.&lt;br /&gt;
&lt;br /&gt;
== Team ==&lt;br /&gt;
&lt;br /&gt;
'''Team Members'''&lt;br /&gt;
&lt;br /&gt;
Reuben M. V. John [[mailto:rmjohn2@ncsu.edu rmjohn2@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Renji Joseph Sabu [[mailto:rsabu@ncsu.edu rsabu@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Ashwin Das [[mailto:adas9@ncsu.edu adas9@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Arnav Julka [[mailto:ajulka@ncsu.edu ajulka@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Mentor'''&lt;br /&gt;
&lt;br /&gt;
Jialin Cui [[mailto:jcui9@ncsu.edu jcui9@ncsu.edu]]&lt;/div&gt;</summary>
		<author><name>Ajulka</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization&amp;diff=140515</id>
		<title>CSC/ECE 517 Fall 2021 - E2159. Expertiza internationalization</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization&amp;diff=140515"/>
		<updated>2021-11-03T01:23:03Z</updated>

		<summary type="html">&lt;p&gt;Ajulka: /* Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction - Purpose &amp;amp; Problem ==&lt;br /&gt;
1. Language selection&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
'''''2 Rendering the language'''''&amp;lt;br&amp;gt;&lt;br /&gt;
'''How do we go about rendering the screen in that language?''' &amp;lt;br&amp;gt;&lt;br /&gt;
In the previous step, we’ve identified the language in which a view is to be rendered. It is important to note that this language may not only differ for a different user, but also for a different page for the same user. The question now becomes, how do we render the screen in this language? To tackle this question, we explore 2 fundamental concepts:&amp;lt;br&amp;gt;&lt;br /&gt;
'''Views are composed of independent language elements'''&amp;lt;br&amp;gt;&lt;br /&gt;
While this is something we typically take for granted, it becomes especially important in the context of translation. That is, a view is not a single contiguous block of text, nor is it an atomic visualization of information (unlike a screenshot), but rather a carefully organized collection of individual elements such as texts, buttons, etc that each contain language that needs to be translated separately. Crucially, this means that we cannot swap out a page in one language in its entirety for a page in another language in its entirety. Instead, each individual element needs to be swapped out individually so as to only impact the language and not the structural composition of the page itself.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''*Views require translation at a large number of call sites'''&amp;lt;br&amp;gt;&lt;br /&gt;
Given that a view is composed of individual elements, this also means that the computation of how to translate such an element such as a button’s text would need to be done separately for each element. This would result in not only a single centralized &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Translation gaps&lt;br /&gt;
&lt;br /&gt;
== Scope ==&lt;br /&gt;
== Design ==&lt;br /&gt;
Proposed Solution&lt;br /&gt;
1. Language selection&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
'''''2. Rendering the language'''''&amp;lt;br&amp;gt;&lt;br /&gt;
Rendering the language&amp;lt;br&amp;gt;&lt;br /&gt;
Once we have determined the language in which to render the page, we now need to update the rails view code to actually generate the appropriate HTML in the target language. This is the responsibility of the view. However, currently, the actual content of the HTML is hardcoded in (red) English. For example:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;Summary Report for assignment: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;Team: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
As discussed earlier, “Views are composed of independent language elements” and so we cannot simply swap out the entire page content for a separate page in another language (Why? - See “swap out the entire view” in the alternative approaches section):&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;Rapport de synthèse pour l'affectation: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;Équipe: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;Instead, the better approach is to have a single unified view that dynamically changes based on the selected language:&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;&amp;lt;%=language==’en’ ? ‘Summary Report for assignment’ : ‘Rapport de synthèse pour l'affectation’&amp;gt;: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;&amp;lt;%=language==’en’ ? ‘Team’ : ‘Équipe’&amp;gt;: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;However this is clearly infeasible considering the number of call sites where we have to apply this logic. Thus, in order to maximize how concise the call site is, we can pull out this logic into a common helper function:&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;&amp;lt;%=localized(“report_summary.page_header”)&amp;gt;: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;&amp;lt;%=localized(“report_summary.team_label”)&amp;gt;: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;Here the assumption is that the localized(“key”) is aware of the currently selected language and that “report_summary.page_header” is the key for the header which is available in English and Hindi. The helper intelligently selects and returns the right text based on the currently selected language. Through this approach, we are able to render the view in multiple possible languages without any significant increase in the verbosity of the view.&lt;br /&gt;
&lt;br /&gt;
What’s more, is that the above problem is a common problem for user-facing applications and a standard library for doing the above and much more already exists for rails applications called i18n&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I18n - Internationalisation, How are we using I18n in Ruby on Rails	7&lt;br /&gt;
3. Translation gaps&lt;br /&gt;
&lt;br /&gt;
== Alternate approaches ==&lt;br /&gt;
== Use Case Diagram ==&lt;br /&gt;
== Major design patterns and principles used ==&lt;br /&gt;
&lt;br /&gt;
'''1. DRY: The i18n ‘t’ function'''&amp;lt;br&amp;gt;&lt;br /&gt;
We observe an extreme case of DRY with the t function of i18n.&lt;br /&gt;
For some background, the t function of the library takes in a key representing a text and returns the content referred to by that key in the preferred language of the user. It also performs many other functions such as falling back to a backup language if the translation for the preferred language has not been configured for that specific key. Thus since this logic has to be applied at every element of the view, it would behove us to extract this logic into a reusable function which is what the designers of the i18n library have employed&lt;br /&gt;
&lt;br /&gt;
'''2. Chain of responsibility'''&amp;lt;br&amp;gt;&lt;br /&gt;
@ajulka&lt;br /&gt;
&lt;br /&gt;
'''3. Open closed principle &amp;amp; Strategy Pattern'''&amp;lt;br&amp;gt;&lt;br /&gt;
As discussed in the “Language selection&amp;quot; design proposal above, if the user has not selected a preferred language, we do not simply default the view to render in the application language (English). Instead, the project requirements state that for course specific screens such as the assignment view, we would need to render the view in the course’s language.&lt;br /&gt;
While we could implement this code into the application controller that checks the controller being access and accordingly applies overrides on the default language, this violates the open closed principle since we would need to extend this logic any time we introduce a new course specific screen. Instead a better approach is to delegate the decision of selecting the language to the view itself since the view would be most aware of whether the view is course specific or not. We can also preserve the DRYness through mix-ins.&lt;br /&gt;
&lt;br /&gt;
== Database Design ==&lt;br /&gt;
Database Modification ==&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
Test Details&lt;br /&gt;
Manual Testing&lt;br /&gt;
Scenario 1&lt;br /&gt;
Scenario 2&lt;br /&gt;
Scenario 3&lt;br /&gt;
Scenario 4&lt;br /&gt;
Scenario 5&lt;br /&gt;
== Future Scope==&lt;br /&gt;
'''1. Expand to more languages'''&amp;lt;br&amp;gt;&lt;br /&gt;
As part of this project we have targetted Hindi as a second language, however our work makes it easy to extend to other languages as well.&lt;br /&gt;
&lt;br /&gt;
'''2. Identify and implement the course language override on more course specific screens'''&amp;lt;br&amp;gt;&lt;br /&gt;
As part of this project, we have introduced a generic framework by which any view can provide a preferred language in which it should be rendered, this is required by this project for the course language feature set by the instructor.&lt;br /&gt;
We have currently made the assignment screen display in the course’s language, however other screens such as the “Your work” screen and so on are also specific to the course could also be rendered in the course language when the user has not provided a preference.&lt;br /&gt;
&lt;br /&gt;
== Team ==&lt;br /&gt;
&lt;br /&gt;
'''Team Members'''&lt;br /&gt;
&lt;br /&gt;
Reuben M. V. John [[mailto:rmjohn2@ncsu.edu rmjohn2@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Renji Joseph Sabu [[mailto:rsabu@ncsu.edu rsabu@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Ashwin Das [[mailto:adas9@ncsu.edu adas9@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Arnav Julka [[mailto:ajulka@ncsu.edu ajulka@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Mentor'''&lt;br /&gt;
&lt;br /&gt;
Jialin Cui [[mailto:jcui9@ncsu.edu jcui9@ncsu.edu]]&lt;/div&gt;</summary>
		<author><name>Ajulka</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization&amp;diff=140514</id>
		<title>CSC/ECE 517 Fall 2021 - E2159. Expertiza internationalization</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization&amp;diff=140514"/>
		<updated>2021-11-03T01:22:23Z</updated>

		<summary type="html">&lt;p&gt;Ajulka: /* Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction - Purpose &amp;amp; Problem ==&lt;br /&gt;
1. Language selection&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
'''''2 Rendering the language'''''&amp;lt;br&amp;gt;&lt;br /&gt;
'''How do we go about rendering the screen in that language?''' &amp;lt;br&amp;gt;&lt;br /&gt;
In the previous step, we’ve identified the language in which a view is to be rendered. It is important to note that this language may not only differ for a different user, but also for a different page for the same user. The question now becomes, how do we render the screen in this language? To tackle this question, we explore 2 fundamental concepts:&amp;lt;br&amp;gt;&lt;br /&gt;
'''Views are composed of independent language elements'''&amp;lt;br&amp;gt;&lt;br /&gt;
While this is something we typically take for granted, it becomes especially important in the context of translation. That is, a view is not a single contiguous block of text, nor is it an atomic visualization of information (unlike a screenshot), but rather a carefully organized collection of individual elements such as texts, buttons, etc that each contain language that needs to be translated separately. Crucially, this means that we cannot swap out a page in one language in its entirety for a page in another language in its entirety. Instead, each individual element needs to be swapped out individually so as to only impact the language and not the structural composition of the page itself.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''*Views require translation at a large number of call sites'''&amp;lt;br&amp;gt;&lt;br /&gt;
Given that a view is composed of individual elements, this also means that the computation of how to translate such an element such as a button’s text would need to be done separately for each element. This would result in not only a single centralized &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Translation gaps&lt;br /&gt;
&lt;br /&gt;
== Scope ==&lt;br /&gt;
== Design ==&lt;br /&gt;
Proposed Solution&lt;br /&gt;
1. Language selection&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
'''''2. Rendering the language'''''&amp;lt;br&amp;gt;&lt;br /&gt;
Rendering the language&amp;lt;br&amp;gt;&lt;br /&gt;
Once we have determined the language in which to render the page, we now need to update the rails view code to actually generate the appropriate HTML in the target language. This is the responsibility of the view. However, currently, the actual content of the HTML is hardcoded in (red) English. For example:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;Summary Report for assignment: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;Team: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
As discussed earlier, “Views are composed of independent language elements” and so we cannot simply swap out the entire page content for a separate page in another language (Why? - See “swap out the entire view” in the alternative approaches section):&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;Rapport de synthèse pour l'affectation: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;Équipe: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;Instead, the better approach is to have a single unified view that dynamically changes based on the selected language:&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;&amp;lt;%=language==’en’ ? ‘Summary Report for assignment’ : ‘Rapport de synthèse pour l'affectation’&amp;gt;: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;&amp;lt;%=language==’en’ ? ‘Team’ : ‘Équipe’&amp;gt;: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;However this is clearly infeasible considering the number of call sites where we have to apply this logic. Thus, in order to maximize how concise the call site is, we can pull out this logic into a common helper function:&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;&amp;lt;%=localized(“report_summary.page_header”)&amp;gt;: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;&amp;lt;%=localized(“report_summary.team_label”)&amp;gt;: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I18n - Internationalisation, How are we using I18n in Ruby on Rails	7&lt;br /&gt;
3. Translation gaps&lt;br /&gt;
&lt;br /&gt;
== Alternate approaches ==&lt;br /&gt;
== Use Case Diagram ==&lt;br /&gt;
== Major design patterns and principles used ==&lt;br /&gt;
&lt;br /&gt;
'''1. DRY: The i18n ‘t’ function'''&amp;lt;br&amp;gt;&lt;br /&gt;
We observe an extreme case of DRY with the t function of i18n.&lt;br /&gt;
For some background, the t function of the library takes in a key representing a text and returns the content referred to by that key in the preferred language of the user. It also performs many other functions such as falling back to a backup language if the translation for the preferred language has not been configured for that specific key. Thus since this logic has to be applied at every element of the view, it would behove us to extract this logic into a reusable function which is what the designers of the i18n library have employed&lt;br /&gt;
&lt;br /&gt;
'''2. Chain of responsibility'''&amp;lt;br&amp;gt;&lt;br /&gt;
@ajulka&lt;br /&gt;
&lt;br /&gt;
'''3. Open closed principle &amp;amp; Strategy Pattern'''&amp;lt;br&amp;gt;&lt;br /&gt;
As discussed in the “Language selection&amp;quot; design proposal above, if the user has not selected a preferred language, we do not simply default the view to render in the application language (English). Instead, the project requirements state that for course specific screens such as the assignment view, we would need to render the view in the course’s language.&lt;br /&gt;
While we could implement this code into the application controller that checks the controller being access and accordingly applies overrides on the default language, this violates the open closed principle since we would need to extend this logic any time we introduce a new course specific screen. Instead a better approach is to delegate the decision of selecting the language to the view itself since the view would be most aware of whether the view is course specific or not. We can also preserve the DRYness through mix-ins.&lt;br /&gt;
&lt;br /&gt;
== Database Design ==&lt;br /&gt;
Database Modification ==&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
Test Details&lt;br /&gt;
Manual Testing&lt;br /&gt;
Scenario 1&lt;br /&gt;
Scenario 2&lt;br /&gt;
Scenario 3&lt;br /&gt;
Scenario 4&lt;br /&gt;
Scenario 5&lt;br /&gt;
== Future Scope==&lt;br /&gt;
'''1. Expand to more languages'''&amp;lt;br&amp;gt;&lt;br /&gt;
As part of this project we have targetted Hindi as a second language, however our work makes it easy to extend to other languages as well.&lt;br /&gt;
&lt;br /&gt;
'''2. Identify and implement the course language override on more course specific screens'''&amp;lt;br&amp;gt;&lt;br /&gt;
As part of this project, we have introduced a generic framework by which any view can provide a preferred language in which it should be rendered, this is required by this project for the course language feature set by the instructor.&lt;br /&gt;
We have currently made the assignment screen display in the course’s language, however other screens such as the “Your work” screen and so on are also specific to the course could also be rendered in the course language when the user has not provided a preference.&lt;br /&gt;
&lt;br /&gt;
== Team ==&lt;br /&gt;
&lt;br /&gt;
'''Team Members'''&lt;br /&gt;
&lt;br /&gt;
Reuben M. V. John [[mailto:rmjohn2@ncsu.edu rmjohn2@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Renji Joseph Sabu [[mailto:rsabu@ncsu.edu rsabu@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Ashwin Das [[mailto:adas9@ncsu.edu adas9@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Arnav Julka [[mailto:ajulka@ncsu.edu ajulka@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Mentor'''&lt;br /&gt;
&lt;br /&gt;
Jialin Cui [[mailto:jcui9@ncsu.edu jcui9@ncsu.edu]]&lt;/div&gt;</summary>
		<author><name>Ajulka</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization&amp;diff=140512</id>
		<title>CSC/ECE 517 Fall 2021 - E2159. Expertiza internationalization</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization&amp;diff=140512"/>
		<updated>2021-11-03T01:19:51Z</updated>

		<summary type="html">&lt;p&gt;Ajulka: /* Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction - Purpose &amp;amp; Problem ==&lt;br /&gt;
1. Language selection&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
'''''2 Rendering the language'''''&amp;lt;br&amp;gt;&lt;br /&gt;
'''How do we go about rendering the screen in that language?''' &amp;lt;br&amp;gt;&lt;br /&gt;
In the previous step, we’ve identified the language in which a view is to be rendered. It is important to note that this language may not only differ for a different user, but also for a different page for the same user. The question now becomes, how do we render the screen in this language? To tackle this question, we explore 2 fundamental concepts:&amp;lt;br&amp;gt;&lt;br /&gt;
'''Views are composed of independent language elements'''&amp;lt;br&amp;gt;&lt;br /&gt;
While this is something we typically take for granted, it becomes especially important in the context of translation. That is, a view is not a single contiguous block of text, nor is it an atomic visualization of information (unlike a screenshot), but rather a carefully organized collection of individual elements such as texts, buttons, etc that each contain language that needs to be translated separately. Crucially, this means that we cannot swap out a page in one language in its entirety for a page in another language in its entirety. Instead, each individual element needs to be swapped out individually so as to only impact the language and not the structural composition of the page itself.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''*Views require translation at a large number of call sites'''&amp;lt;br&amp;gt;&lt;br /&gt;
Given that a view is composed of individual elements, this also means that the computation of how to translate such an element such as a button’s text would need to be done separately for each element. This would result in not only a single centralized &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Translation gaps&lt;br /&gt;
&lt;br /&gt;
== Scope ==&lt;br /&gt;
== Design ==&lt;br /&gt;
Proposed Solution&lt;br /&gt;
1. Language selection&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
'''2. Rendering the language'''&amp;lt;br&amp;gt;&lt;br /&gt;
Rendering the language&amp;lt;br&amp;gt;&lt;br /&gt;
Once we have determined the language in which to render the page, we now need to update the rails view code to actually generate the appropriate HTML in the target language. This is the responsibility of the view. However, currently, the actual content of the HTML is hardcoded in (red) English. For example:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;Summary Report for assignment: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;Team: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
As discussed earlier, “Views are composed of independent language elements” and so we cannot simply swap out the entire page content for a separate page in another language (Why? - See “swap out the entire view” in the alternative approaches section):&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;Rapport de synthèse pour l'affectation: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;Équipe: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
I18n - Internationalisation, How are we using I18n in Ruby on Rails	7&lt;br /&gt;
3. Translation gaps&lt;br /&gt;
&lt;br /&gt;
== Alternate approaches ==&lt;br /&gt;
== Use Case Diagram ==&lt;br /&gt;
== Major design patterns and principles used ==&lt;br /&gt;
== Database Design ==&lt;br /&gt;
Database Modification ==&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
Test Details&lt;br /&gt;
Manual Testing&lt;br /&gt;
Scenario 1&lt;br /&gt;
Scenario 2&lt;br /&gt;
Scenario 3&lt;br /&gt;
Scenario 4&lt;br /&gt;
Scenario 5&lt;br /&gt;
== Future Scope==&lt;br /&gt;
'''1. Expand to more languages'''&amp;lt;br&amp;gt;&lt;br /&gt;
As part of this project we have targetted Hindi as a second language, however our work makes it easy to extend to other languages as well.&lt;br /&gt;
&lt;br /&gt;
'''2. Identify and implement the course language override on more course specific screens'''&amp;lt;br&amp;gt;&lt;br /&gt;
As part of this project, we have introduced a generic framework by which any view can provide a preferred language in which it should be rendered, this is required by this project for the course language feature set by the instructor.&lt;br /&gt;
We have currently made the assignment screen display in the course’s language, however other screens such as the “Your work” screen and so on are also specific to the course could also be rendered in the course language when the user has not provided a preference.&lt;br /&gt;
&lt;br /&gt;
== Team ==&lt;br /&gt;
&lt;br /&gt;
'''Team Members'''&lt;br /&gt;
&lt;br /&gt;
Reuben M. V. John [[mailto:rmjohn2@ncsu.edu rmjohn2@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Renji Joseph Sabu [[mailto:rsabu@ncsu.edu rsabu@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Ashwin Das [[mailto:adas9@ncsu.edu adas9@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Arnav Julka [[mailto:ajulka@ncsu.edu ajulka@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Mentor'''&lt;br /&gt;
&lt;br /&gt;
Jialin Cui [[mailto:jcui9@ncsu.edu jcui9@ncsu.edu]]&lt;/div&gt;</summary>
		<author><name>Ajulka</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization&amp;diff=140511</id>
		<title>CSC/ECE 517 Fall 2021 - E2159. Expertiza internationalization</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization&amp;diff=140511"/>
		<updated>2021-11-03T01:18:58Z</updated>

		<summary type="html">&lt;p&gt;Ajulka: /* Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction - Purpose &amp;amp; Problem ==&lt;br /&gt;
1. Language selection&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
'''''2 Rendering the language'''''&amp;lt;br&amp;gt;&lt;br /&gt;
'''How do we go about rendering the screen in that language?''' &amp;lt;br&amp;gt;&lt;br /&gt;
In the previous step, we’ve identified the language in which a view is to be rendered. It is important to note that this language may not only differ for a different user, but also for a different page for the same user. The question now becomes, how do we render the screen in this language? To tackle this question, we explore 2 fundamental concepts:&amp;lt;br&amp;gt;&lt;br /&gt;
'''Views are composed of independent language elements'''&amp;lt;br&amp;gt;&lt;br /&gt;
While this is something we typically take for granted, it becomes especially important in the context of translation. That is, a view is not a single contiguous block of text, nor is it an atomic visualization of information (unlike a screenshot), but rather a carefully organized collection of individual elements such as texts, buttons, etc that each contain language that needs to be translated separately. Crucially, this means that we cannot swap out a page in one language in its entirety for a page in another language in its entirety. Instead, each individual element needs to be swapped out individually so as to only impact the language and not the structural composition of the page itself.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''*Views require translation at a large number of call sites'''&amp;lt;br&amp;gt;&lt;br /&gt;
Given that a view is composed of individual elements, this also means that the computation of how to translate such an element such as a button’s text would need to be done separately for each element. This would result in not only a single centralized &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Translation gaps&lt;br /&gt;
&lt;br /&gt;
== Scope ==&lt;br /&gt;
== Design ==&lt;br /&gt;
Proposed Solution&lt;br /&gt;
1. Language selection&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
'''2. Rendering the language'''&amp;lt;br&amp;gt;&lt;br /&gt;
Rendering the language&amp;lt;br&amp;gt;&lt;br /&gt;
Once we have determined the language in which to render the page, we now need to update the rails view code to actually generate the appropriate HTML in the target language. This is the responsibility of the view. However, currently, the actual content of the HTML is hardcoded in (red) English. For example:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;h2&amp;gt;Summary Report for assignment: &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;Team: &amp;lt;%= @team.name %&amp;gt;&amp;lt;/h4&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I18n - Internationalisation, How are we using I18n in Ruby on Rails	7&lt;br /&gt;
3. Translation gaps&lt;br /&gt;
&lt;br /&gt;
== Alternate approaches ==&lt;br /&gt;
== Use Case Diagram ==&lt;br /&gt;
== Major design patterns and principles used ==&lt;br /&gt;
== Database Design ==&lt;br /&gt;
Database Modification ==&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
Test Details&lt;br /&gt;
Manual Testing&lt;br /&gt;
Scenario 1&lt;br /&gt;
Scenario 2&lt;br /&gt;
Scenario 3&lt;br /&gt;
Scenario 4&lt;br /&gt;
Scenario 5&lt;br /&gt;
== Future Scope==&lt;br /&gt;
'''1. Expand to more languages'''&amp;lt;br&amp;gt;&lt;br /&gt;
As part of this project we have targetted Hindi as a second language, however our work makes it easy to extend to other languages as well.&lt;br /&gt;
&lt;br /&gt;
'''2. Identify and implement the course language override on more course specific screens'''&amp;lt;br&amp;gt;&lt;br /&gt;
As part of this project, we have introduced a generic framework by which any view can provide a preferred language in which it should be rendered, this is required by this project for the course language feature set by the instructor.&lt;br /&gt;
We have currently made the assignment screen display in the course’s language, however other screens such as the “Your work” screen and so on are also specific to the course could also be rendered in the course language when the user has not provided a preference.&lt;br /&gt;
&lt;br /&gt;
== Team ==&lt;br /&gt;
&lt;br /&gt;
'''Team Members'''&lt;br /&gt;
&lt;br /&gt;
Reuben M. V. John [[mailto:rmjohn2@ncsu.edu rmjohn2@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Renji Joseph Sabu [[mailto:rsabu@ncsu.edu rsabu@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Ashwin Das [[mailto:adas9@ncsu.edu adas9@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Arnav Julka [[mailto:ajulka@ncsu.edu ajulka@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Mentor'''&lt;br /&gt;
&lt;br /&gt;
Jialin Cui [[mailto:jcui9@ncsu.edu jcui9@ncsu.edu]]&lt;/div&gt;</summary>
		<author><name>Ajulka</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization&amp;diff=140509</id>
		<title>CSC/ECE 517 Fall 2021 - E2159. Expertiza internationalization</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization&amp;diff=140509"/>
		<updated>2021-11-03T01:16:40Z</updated>

		<summary type="html">&lt;p&gt;Ajulka: /* Introduction - Purpose &amp;amp; Problem */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction - Purpose &amp;amp; Problem ==&lt;br /&gt;
1. Language selection&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
'''''2 Rendering the language'''''&amp;lt;br&amp;gt;&lt;br /&gt;
'''How do we go about rendering the screen in that language?''' &amp;lt;br&amp;gt;&lt;br /&gt;
In the previous step, we’ve identified the language in which a view is to be rendered. It is important to note that this language may not only differ for a different user, but also for a different page for the same user. The question now becomes, how do we render the screen in this language? To tackle this question, we explore 2 fundamental concepts:&amp;lt;br&amp;gt;&lt;br /&gt;
'''Views are composed of independent language elements'''&amp;lt;br&amp;gt;&lt;br /&gt;
While this is something we typically take for granted, it becomes especially important in the context of translation. That is, a view is not a single contiguous block of text, nor is it an atomic visualization of information (unlike a screenshot), but rather a carefully organized collection of individual elements such as texts, buttons, etc that each contain language that needs to be translated separately. Crucially, this means that we cannot swap out a page in one language in its entirety for a page in another language in its entirety. Instead, each individual element needs to be swapped out individually so as to only impact the language and not the structural composition of the page itself.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''*Views require translation at a large number of call sites'''&amp;lt;br&amp;gt;&lt;br /&gt;
Given that a view is composed of individual elements, this also means that the computation of how to translate such an element such as a button’s text would need to be done separately for each element. This would result in not only a single centralized &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Translation gaps&lt;br /&gt;
&lt;br /&gt;
== Scope ==&lt;br /&gt;
== Design ==&lt;br /&gt;
Proposed Solution&lt;br /&gt;
1. Language selection&lt;br /&gt;
2. Rendering the language&lt;br /&gt;
I18n - Internationalisation, How are we using I18n in Ruby on Rails	7&lt;br /&gt;
3. Translation gaps&lt;br /&gt;
== Alternate approaches ==&lt;br /&gt;
== Use Case Diagram ==&lt;br /&gt;
== Major design patterns and principles used ==&lt;br /&gt;
== Database Design ==&lt;br /&gt;
Database Modification ==&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
Test Details&lt;br /&gt;
Manual Testing&lt;br /&gt;
Scenario 1&lt;br /&gt;
Scenario 2&lt;br /&gt;
Scenario 3&lt;br /&gt;
Scenario 4&lt;br /&gt;
Scenario 5&lt;br /&gt;
== Future Scope==&lt;br /&gt;
== Team ==&lt;br /&gt;
&lt;br /&gt;
'''Team Members'''&lt;br /&gt;
&lt;br /&gt;
Reuben M. V. John [[mailto:rmjohn2@ncsu.edu rmjohn2@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Renji Joseph Sabu [[mailto:rsabu@ncsu.edu rsabu@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Ashwin Das [[mailto:adas9@ncsu.edu adas9@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Arnav Julka [[mailto:ajulka@ncsu.edu ajulka@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Mentor'''&lt;br /&gt;
&lt;br /&gt;
Jialin Cui [[mailto:jcui9@ncsu.edu jcui9@ncsu.edu]]&lt;/div&gt;</summary>
		<author><name>Ajulka</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization&amp;diff=140508</id>
		<title>CSC/ECE 517 Fall 2021 - E2159. Expertiza internationalization</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization&amp;diff=140508"/>
		<updated>2021-11-03T01:16:28Z</updated>

		<summary type="html">&lt;p&gt;Ajulka: /* Introduction - Purpose &amp;amp; Problem */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction - Purpose &amp;amp; Problem ==&lt;br /&gt;
1. Language selection&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
'''''2 Rendering the language'''''&amp;lt;br&amp;gt;&amp;lt;br&lt;br /&gt;
'''How do we go about rendering the screen in that language?''' &amp;lt;br&amp;gt;&lt;br /&gt;
In the previous step, we’ve identified the language in which a view is to be rendered. It is important to note that this language may not only differ for a different user, but also for a different page for the same user. The question now becomes, how do we render the screen in this language? To tackle this question, we explore 2 fundamental concepts:&amp;lt;br&amp;gt;&lt;br /&gt;
'''Views are composed of independent language elements'''&amp;lt;br&amp;gt;&lt;br /&gt;
While this is something we typically take for granted, it becomes especially important in the context of translation. That is, a view is not a single contiguous block of text, nor is it an atomic visualization of information (unlike a screenshot), but rather a carefully organized collection of individual elements such as texts, buttons, etc that each contain language that needs to be translated separately. Crucially, this means that we cannot swap out a page in one language in its entirety for a page in another language in its entirety. Instead, each individual element needs to be swapped out individually so as to only impact the language and not the structural composition of the page itself.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''*Views require translation at a large number of call sites'''&amp;lt;br&amp;gt;&lt;br /&gt;
Given that a view is composed of individual elements, this also means that the computation of how to translate such an element such as a button’s text would need to be done separately for each element. This would result in not only a single centralized &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Translation gaps&lt;br /&gt;
&lt;br /&gt;
== Scope ==&lt;br /&gt;
== Design ==&lt;br /&gt;
Proposed Solution&lt;br /&gt;
1. Language selection&lt;br /&gt;
2. Rendering the language&lt;br /&gt;
I18n - Internationalisation, How are we using I18n in Ruby on Rails	7&lt;br /&gt;
3. Translation gaps&lt;br /&gt;
== Alternate approaches ==&lt;br /&gt;
== Use Case Diagram ==&lt;br /&gt;
== Major design patterns and principles used ==&lt;br /&gt;
== Database Design ==&lt;br /&gt;
Database Modification ==&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
Test Details&lt;br /&gt;
Manual Testing&lt;br /&gt;
Scenario 1&lt;br /&gt;
Scenario 2&lt;br /&gt;
Scenario 3&lt;br /&gt;
Scenario 4&lt;br /&gt;
Scenario 5&lt;br /&gt;
== Future Scope==&lt;br /&gt;
== Team ==&lt;br /&gt;
&lt;br /&gt;
'''Team Members'''&lt;br /&gt;
&lt;br /&gt;
Reuben M. V. John [[mailto:rmjohn2@ncsu.edu rmjohn2@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Renji Joseph Sabu [[mailto:rsabu@ncsu.edu rsabu@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Ashwin Das [[mailto:adas9@ncsu.edu adas9@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
Arnav Julka [[mailto:ajulka@ncsu.edu ajulka@ncsu.edu]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Mentor'''&lt;br /&gt;
&lt;br /&gt;
Jialin Cui [[mailto:jcui9@ncsu.edu jcui9@ncsu.edu]]&lt;/div&gt;</summary>
		<author><name>Ajulka</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization&amp;diff=140506</id>
		<title>CSC/ECE 517 Fall 2021 - E2159. Expertiza internationalization</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization&amp;diff=140506"/>
		<updated>2021-11-03T01:16:13Z</updated>

		<summary type="html">&lt;p&gt;Ajulka: /* Introduction - Purpose &amp;amp; Problem */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction - Purpose &amp;amp; Problem ==&lt;br /&gt;
1. Language selection&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''''2 Rendering the language'''''&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
'''How do we go about rendering the screen in that language?''' &amp;lt;br&amp;gt;&lt;br /&gt;
In the previous step, we’ve identified the language in which a view is to be rendered. It is important to note that this language may not only differ for a different user, but also for a different page for the same user. The question now becomes, how do we render the screen in this language? To tackle this question, we explore 2 fundamental concepts:&amp;lt;br&amp;gt;&lt;br /&gt;
'''Views are composed of independent language elements'''&amp;lt;br&amp;gt;&lt;br /&gt;
While this is something we typically take for granted, it becomes especially important in the context of translation. That is, a view is not a single contiguous block of text, nor is it an atomic visualization of information (unlike a screenshot), but rather a carefully organized collection of individual elements such as texts, buttons, etc that each contain language that needs to be translated separately. Crucially, this means that we cannot swap out a page in one language in its entirety for a page in another language in its entirety. Instead, each individual element needs to be swapped out individually so as to only impact the language and not the structural composition of the page itself.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''*Views require translation at a large number of call sites'''&amp;lt;br&amp;gt;&lt;br /&gt;
Given that a view is composed of individual elements, this also means that the computation of how to translate such an element such as a button’s text would need to be done separately for each element. This would result in not only a single centralized &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Translation gaps&lt;br /&gt;
&lt;br /&gt;
== Scope ==&lt;br /&gt;
== Design ==&lt;br /&gt;
Proposed Solution&lt;br /&gt;
1. Language selection&lt;br /&gt;
2. Rendering the language&lt;br /&gt;
I18n - Internationalisation, How are we using I18n in Ruby on Rails	7&lt;br /&gt;
3. Translation gaps&lt;br /&gt;
== Alternate approaches ==&lt;br /&gt;
== Use Case Diagram ==&lt;br /&gt;
== Major design patterns and principles used ==&lt;br /&gt;
== Database Design ==&lt;br /&gt;
Database Modification ==&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
Test Details&lt;br /&gt;
Manual Testing&lt;br /&gt;
Scenario 1&lt;br /&gt;
Scenario 2&lt;br /&gt;
Scenario 3&lt;br /&gt;
Scenario 4&lt;br /&gt;
Scenario 5&lt;br /&gt;
== Future Scope==&lt;br /&gt;
== Team ==&lt;/div&gt;</summary>
		<author><name>Ajulka</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization&amp;diff=140505</id>
		<title>CSC/ECE 517 Fall 2021 - E2159. Expertiza internationalization</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization&amp;diff=140505"/>
		<updated>2021-11-03T01:15:54Z</updated>

		<summary type="html">&lt;p&gt;Ajulka: /* Introduction - Purpose &amp;amp; Problem */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction - Purpose &amp;amp; Problem ==&lt;br /&gt;
1. Language selection&lt;br /&gt;
&lt;br /&gt;
'''''2 Rendering the language'''''&amp;lt;br&amp;gt;&lt;br /&gt;
'''How do we go about rendering the screen in that language?''' &amp;lt;br&amp;gt;&lt;br /&gt;
In the previous step, we’ve identified the language in which a view is to be rendered. It is important to note that this language may not only differ for a different user, but also for a different page for the same user. The question now becomes, how do we render the screen in this language? To tackle this question, we explore 2 fundamental concepts:&amp;lt;br&amp;gt;&lt;br /&gt;
'''Views are composed of independent language elements'''&amp;lt;br&amp;gt;&lt;br /&gt;
While this is something we typically take for granted, it becomes especially important in the context of translation. That is, a view is not a single contiguous block of text, nor is it an atomic visualization of information (unlike a screenshot), but rather a carefully organized collection of individual elements such as texts, buttons, etc that each contain language that needs to be translated separately. Crucially, this means that we cannot swap out a page in one language in its entirety for a page in another language in its entirety. Instead, each individual element needs to be swapped out individually so as to only impact the language and not the structural composition of the page itself.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''*Views require translation at a large number of call sites'''&amp;lt;br&amp;gt;&lt;br /&gt;
Given that a view is composed of individual elements, this also means that the computation of how to translate such an element such as a button’s text would need to be done separately for each element. This would result in not only a single centralized &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Translation gaps&lt;br /&gt;
&lt;br /&gt;
== Scope ==&lt;br /&gt;
== Design ==&lt;br /&gt;
Proposed Solution&lt;br /&gt;
1. Language selection&lt;br /&gt;
2. Rendering the language&lt;br /&gt;
I18n - Internationalisation, How are we using I18n in Ruby on Rails	7&lt;br /&gt;
3. Translation gaps&lt;br /&gt;
== Alternate approaches ==&lt;br /&gt;
== Use Case Diagram ==&lt;br /&gt;
== Major design patterns and principles used ==&lt;br /&gt;
== Database Design ==&lt;br /&gt;
Database Modification ==&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
Test Details&lt;br /&gt;
Manual Testing&lt;br /&gt;
Scenario 1&lt;br /&gt;
Scenario 2&lt;br /&gt;
Scenario 3&lt;br /&gt;
Scenario 4&lt;br /&gt;
Scenario 5&lt;br /&gt;
== Future Scope==&lt;br /&gt;
== Team ==&lt;/div&gt;</summary>
		<author><name>Ajulka</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021&amp;diff=140503</id>
		<title>CSC/ECE 517 Fall 2021</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021&amp;diff=140503"/>
		<updated>2021-11-03T01:07:22Z</updated>

		<summary type="html">&lt;p&gt;Ajulka: /* Final Projects */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== OSS Projects ==&lt;br /&gt;
&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2117. Refactor questionaires_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2128. Refactor student_quizzes_controller.rb &amp;amp; late_policies_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2129. Refactor auth_controller.rb &amp;amp; password_retrieval_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2132. Add tests cases for review mapping helper.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2134. Write unit tests for admin_controller.rb and institution_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2138. Auto-generate submission directory names based on assignment]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2142. Improve e-mail notifications]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2133. Write tests for popup_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2120. Refactor reputation_web_service_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2139. Remove multiple topics at a time]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2131. Improve assessment360_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2121. Refactor suggestion_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2122. Refactor impersonate_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2123. Refactor sign_up_sheet_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2126. Refactor account_request_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2124. Refactor review_mapping_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2125. Refactor review_mapping_helper.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2127. Refactor teams_controller]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2130. Refactor submitted_content_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2140. Create new late policy successfully and fix Bank link]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2141. OSS project Finklestein: Instructors &amp;amp; Institutions]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2144. Refactor delayed mailer and scheduled task]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2147. Role-based reviewing]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2145. OSS Project Beige]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2146. Introduce a Student View for instructors]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - Refactor Evaluation of SQL Queries]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2135. Email notification to reviewers and instructors]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2168. Testing - Reputations]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2166. Testing - Scoring &amp;amp; Grades]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2149. Finish Github metrics integration - Reputations]]&lt;br /&gt;
&lt;br /&gt;
== Final Projects ==&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2150._Integrate_suggestion_detection_algorithm#Description_about_project CSC/ECE 517 Fall 2021 - E2150. Integrate suggestion detection algorithm]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2151._Allow_reviewers_to_bid_on_what_to_review CSC/ECE 517 Fall 2021 - E2151. Allow reviewers to bid on what to review]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2152._Revision_planning_tool#Description_about_project CSC/ECE 517 Fall 2021 - E2152. Revision_planning_tool]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2170._Testing_-_Response_Maps#Description_about_project CSC/ECE 517 Fall 2021 - E2170. Testing - Response Maps]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2153._Improving_search_facility_in_Expertiza#Description_about_project CSC/ECE 517 Fall 2021 - E2153. Improving search facility in Expertiza]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2162._Further_refactoring_and_improvement_of_review_mapping_helper CSC/ECE 517 Fall 2021 - E2162. Further refactoring and improvement of review mapping helper]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2165._Fix_teammate-review_view CSC/ECE 517 Fall 2021 - E2165. Fix teammate review view ]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2158._Grading_audit_trail CSC/ECE 517 Fall 2021 - E2158. Grading audit trail ]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2155._Calibration_submissions_should_be_copied_along_with_calibration_assignments CSC/ECE 517 Fall 2021 - E2155. Calibration submissions should be copied along with calibration assignments]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2148._Completion/Progress_View CSC/ECE 517 Fall 2021 - E2148. Completion/Progress view]&lt;br /&gt;
*[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization CSC/ECE 517 Fall 2021 - E2159. Expertiza internationalization]&lt;/div&gt;</summary>
		<author><name>Ajulka</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=E2159_Expertiza_internationalization&amp;diff=140502</id>
		<title>E2159 Expertiza internationalization</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=E2159_Expertiza_internationalization&amp;diff=140502"/>
		<updated>2021-11-03T01:05:50Z</updated>

		<summary type="html">&lt;p&gt;Ajulka: Ajulka moved page E2159 Expertiza internationalization to CSC/ECE 517 Fall 2021 - E2159. Expertiza internationalization&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[CSC/ECE 517 Fall 2021 - E2159. Expertiza internationalization]]&lt;/div&gt;</summary>
		<author><name>Ajulka</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization&amp;diff=140501</id>
		<title>CSC/ECE 517 Fall 2021 - E2159. Expertiza internationalization</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization&amp;diff=140501"/>
		<updated>2021-11-03T01:05:50Z</updated>

		<summary type="html">&lt;p&gt;Ajulka: Ajulka moved page E2159 Expertiza internationalization to CSC/ECE 517 Fall 2021 - E2159. Expertiza internationalization&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction - Purpose &amp;amp; Problem ==&lt;br /&gt;
1. Language selection&lt;br /&gt;
2. Rendering the language&lt;br /&gt;
3. Translation gaps&lt;br /&gt;
&lt;br /&gt;
== Scope ==&lt;br /&gt;
Design	5&lt;br /&gt;
Proposed Solution	5&lt;br /&gt;
Language selection	5&lt;br /&gt;
Rendering the language	6&lt;br /&gt;
I18n - Internationalisation, How are we using I18n in Ruby on Rails	7&lt;br /&gt;
Translation gaps	8&lt;br /&gt;
Alternate approaches	8&lt;br /&gt;
Use Case Diagram	9&lt;br /&gt;
Major design patterns and principles used	9&lt;br /&gt;
Database Design	10&lt;br /&gt;
Database Modification	10&lt;br /&gt;
Test Plan	12&lt;br /&gt;
Test Details	12&lt;br /&gt;
Manual Testing	12&lt;br /&gt;
Scenario 1	12&lt;br /&gt;
Scenario 2	13&lt;br /&gt;
Scenario 3	13&lt;br /&gt;
Scenario 4	13&lt;br /&gt;
Scenario 5	13&lt;br /&gt;
UI Testing	14&lt;br /&gt;
Automated testing using Rspec	14&lt;br /&gt;
Future Scope	14&lt;br /&gt;
Team&lt;/div&gt;</summary>
		<author><name>Ajulka</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021&amp;diff=140498</id>
		<title>CSC/ECE 517 Fall 2021</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021&amp;diff=140498"/>
		<updated>2021-11-03T01:02:53Z</updated>

		<summary type="html">&lt;p&gt;Ajulka: /* Final Projects */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== OSS Projects ==&lt;br /&gt;
&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2117. Refactor questionaires_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2128. Refactor student_quizzes_controller.rb &amp;amp; late_policies_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2129. Refactor auth_controller.rb &amp;amp; password_retrieval_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2132. Add tests cases for review mapping helper.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2134. Write unit tests for admin_controller.rb and institution_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2138. Auto-generate submission directory names based on assignment]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2142. Improve e-mail notifications]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2133. Write tests for popup_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2120. Refactor reputation_web_service_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2139. Remove multiple topics at a time]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2131. Improve assessment360_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2121. Refactor suggestion_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2122. Refactor impersonate_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2123. Refactor sign_up_sheet_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2126. Refactor account_request_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2124. Refactor review_mapping_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2125. Refactor review_mapping_helper.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2127. Refactor teams_controller]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2130. Refactor submitted_content_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2140. Create new late policy successfully and fix Bank link]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2141. OSS project Finklestein: Instructors &amp;amp; Institutions]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2144. Refactor delayed mailer and scheduled task]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2147. Role-based reviewing]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2145. OSS Project Beige]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2146. Introduce a Student View for instructors]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - Refactor Evaluation of SQL Queries]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2135. Email notification to reviewers and instructors]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2168. Testing - Reputations]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2166. Testing - Scoring &amp;amp; Grades]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2149. Finish Github metrics integration - Reputations]]&lt;br /&gt;
&lt;br /&gt;
== Final Projects ==&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2150._Integrate_suggestion_detection_algorithm#Description_about_project CSC/ECE 517 Fall 2021 - E2150. Integrate suggestion detection algorithm]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2151._Allow_reviewers_to_bid_on_what_to_review CSC/ECE 517 Fall 2021 - E2151. Allow reviewers to bid on what to review]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2152._Revision_planning_tool#Description_about_project CSC/ECE 517 Fall 2021 - E2152. Revision_planning_tool]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2170._Testing_-_Response_Maps#Description_about_project CSC/ECE 517 Fall 2021 - E2170. Testing - Response Maps]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2153._Improving_search_facility_in_Expertiza#Description_about_project CSC/ECE 517 Fall 2021 - E2153. Improving search facility in Expertiza]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2162._Further_refactoring_and_improvement_of_review_mapping_helper CSC/ECE 517 Fall 2021 - E2162. Further refactoring and improvement of review mapping helper]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2165._Fix_teammate-review_view CSC/ECE 517 Fall 2021 - E2165. Fix teammate review view ]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2158._Grading_audit_trail CSC/ECE 517 Fall 2021 - E2158. Grading audit trail ]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2155._Calibration_submissions_should_be_copied_along_with_calibration_assignments CSC/ECE 517 Fall 2021 - E2155. Calibration submissions should be copied along with calibration assignments]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2148._Completion/Progress_View CSC/ECE 517 Fall 2021 - E2148. Completion/Progress view]&lt;br /&gt;
*[https://expertiza.csc.ncsu.edu/index.php/E2159_Expertiza_internationalization]&lt;/div&gt;</summary>
		<author><name>Ajulka</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021&amp;diff=140497</id>
		<title>CSC/ECE 517 Fall 2021</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021&amp;diff=140497"/>
		<updated>2021-11-03T01:02:14Z</updated>

		<summary type="html">&lt;p&gt;Ajulka: /* Final Projects */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== OSS Projects ==&lt;br /&gt;
&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2117. Refactor questionaires_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2128. Refactor student_quizzes_controller.rb &amp;amp; late_policies_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2129. Refactor auth_controller.rb &amp;amp; password_retrieval_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2132. Add tests cases for review mapping helper.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2134. Write unit tests for admin_controller.rb and institution_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2138. Auto-generate submission directory names based on assignment]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2142. Improve e-mail notifications]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2133. Write tests for popup_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2120. Refactor reputation_web_service_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2139. Remove multiple topics at a time]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2131. Improve assessment360_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2121. Refactor suggestion_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2122. Refactor impersonate_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2123. Refactor sign_up_sheet_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2126. Refactor account_request_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2124. Refactor review_mapping_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2125. Refactor review_mapping_helper.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2127. Refactor teams_controller]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2130. Refactor submitted_content_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2140. Create new late policy successfully and fix Bank link]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2141. OSS project Finklestein: Instructors &amp;amp; Institutions]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2144. Refactor delayed mailer and scheduled task]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2147. Role-based reviewing]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2145. OSS Project Beige]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2146. Introduce a Student View for instructors]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - Refactor Evaluation of SQL Queries]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2135. Email notification to reviewers and instructors]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2168. Testing - Reputations]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2166. Testing - Scoring &amp;amp; Grades]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2149. Finish Github metrics integration - Reputations]]&lt;br /&gt;
&lt;br /&gt;
== Final Projects ==&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2150._Integrate_suggestion_detection_algorithm#Description_about_project CSC/ECE 517 Fall 2021 - E2150. Integrate suggestion detection algorithm]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2151._Allow_reviewers_to_bid_on_what_to_review CSC/ECE 517 Fall 2021 - E2151. Allow reviewers to bid on what to review]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2152._Revision_planning_tool#Description_about_project CSC/ECE 517 Fall 2021 - E2152. Revision_planning_tool]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2170._Testing_-_Response_Maps#Description_about_project CSC/ECE 517 Fall 2021 - E2170. Testing - Response Maps]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2153._Improving_search_facility_in_Expertiza#Description_about_project CSC/ECE 517 Fall 2021 - E2153. Improving search facility in Expertiza]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2162._Further_refactoring_and_improvement_of_review_mapping_helper CSC/ECE 517 Fall 2021 - E2162. Further refactoring and improvement of review mapping helper]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2165._Fix_teammate-review_view CSC/ECE 517 Fall 2021 - E2165. Fix teammate review view ]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2158._Grading_audit_trail CSC/ECE 517 Fall 2021 - E2158. Grading audit trail ]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2155._Calibration_submissions_should_be_copied_along_with_calibration_assignments CSC/ECE 517 Fall 2021 - E2155. Calibration submissions should be copied along with calibration assignments]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2148._Completion/Progress_View CSC/ECE 517 Fall 2021 - E2148. Completion/Progress view]&lt;br /&gt;
[[https://expertiza.csc.ncsu.edu/index.php/E2159_Expertiza_internationalization]]&lt;/div&gt;</summary>
		<author><name>Ajulka</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization&amp;diff=140496</id>
		<title>CSC/ECE 517 Fall 2021 - E2159. Expertiza internationalization</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization&amp;diff=140496"/>
		<updated>2021-11-03T01:00:51Z</updated>

		<summary type="html">&lt;p&gt;Ajulka: E2159 Expertiza internationalization&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;heloooooo&lt;/div&gt;</summary>
		<author><name>Ajulka</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2142._Improve_e-mail_notifications&amp;diff=139593</id>
		<title>CSC/ECE 517 Fall 2021 - E2142. Improve e-mail notifications</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2142._Improve_e-mail_notifications&amp;diff=139593"/>
		<updated>2021-10-20T23:57:03Z</updated>

		<summary type="html">&lt;p&gt;Ajulka: /* Issue - Don't send email to reviewers for a new submission after the review deadline has passed */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E2142. Improve e-mail notifications=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Work in progress==&lt;br /&gt;
This project is ongoing, and this page will be updated live.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Issue - Don't send email to reviewers for a new submission after the review deadline has passed ==&lt;br /&gt;
&lt;br /&gt;
'''Pre conditions'''&lt;br /&gt;
* There is an assignment, a student as a participant, a participant as a reviewer who is reviewing the this particular assignment&lt;br /&gt;
* a review is made for a submission by the student&lt;br /&gt;
* review deadline has passed&lt;br /&gt;
* the student is allowed to submit after the review deadline has passed&lt;br /&gt;
&lt;br /&gt;
'''Expected Behavior'''&lt;br /&gt;
&lt;br /&gt;
Exact issue stating the expected behavior can be found at https://github.com/expertiza/expertiza/issues/345 - &lt;br /&gt;
&amp;quot;Evidently, if a submission is revised after review, the system e-mails the reviewer saying to revise the review. This is just fine ... except if the last round of review has been completed.&lt;br /&gt;
The message telling reviewers to revise their reviews should not be sent after the last review deadline has passed.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
So basically, When the student makes a new submission after the LAST review deadline has passed. The reviewer should not receive an email, asking the reviewer to update the review according to the new submission.&lt;br /&gt;
&lt;br /&gt;
'''Actual Behavior'''&lt;br /&gt;
&lt;br /&gt;
According to the current Code scenario on the beta branch '''''if the deadline has passed, a student(participant) cannot make new submissions'''''. So, automatically if the participant doe not make a new submission then the reviewer wont receive an email. So this issue does not really exist by the virtue of the state of the system.&lt;br /&gt;
the stack trace for the check if the submission is allowed or not is as follows - &lt;br /&gt;
assignment.rb&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def submission_allowed(topic_id = nil)&lt;br /&gt;
    check_condition('submission_allowed_id', topic_id)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
assignment.rb&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def check_condition(column, topic_id = nil)&lt;br /&gt;
    next_due_date = DueDate.get_next_due_date(self.id, topic_id)&lt;br /&gt;
    return false if next_due_date.nil?&lt;br /&gt;
    right_id = next_due_date.send column&lt;br /&gt;
    right = DeadlineRight.find(right_id)&lt;br /&gt;
    right &amp;amp;&amp;amp; (right.name == 'OK' || right.name == 'Late')&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
due_date.rb&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    def self.get_next_due_date(assignment_id, topic_id = nil)&lt;br /&gt;
    if Assignment.find(assignment_id).staggered_deadline?&lt;br /&gt;
      next_due_date = TopicDueDate.find_by(['parent_id = ? and due_at &amp;gt;= ?', topic_id, Time.zone.now])&lt;br /&gt;
      # if certion TopicDueDate is not exist, we should query next corresponding AssignmentDueDate.&lt;br /&gt;
      # eg. Time.now is 08/28/2016&lt;br /&gt;
      # One topic uses following deadlines:&lt;br /&gt;
      # TopicDueDate      08/01/2016&lt;br /&gt;
      # TopicDueDate      08/02/2016&lt;br /&gt;
      # TopicDueDate      08/03/2016&lt;br /&gt;
      # AssignmentDueDate 09/04/2016&lt;br /&gt;
      # In this case, we cannot find due_at later than Time.now in TopicDueDate.&lt;br /&gt;
      # So we should find next corrsponding AssignmentDueDate, starting with the 4th one, not the 1st one!&lt;br /&gt;
      if next_due_date.nil?&lt;br /&gt;
        topic_due_date_size = TopicDueDate.where(parent_id: topic_id).size&lt;br /&gt;
        following_assignment_due_dates = AssignmentDueDate.where(parent_id: assignment_id)[topic_due_date_size..-1]&lt;br /&gt;
        unless following_assignment_due_dates.nil?&lt;br /&gt;
          following_assignment_due_dates.each do |assignment_due_date|&lt;br /&gt;
            if assignment_due_date.due_at &amp;gt;= Time.zone.now&lt;br /&gt;
              next_due_date = assignment_due_date&lt;br /&gt;
              break&lt;br /&gt;
            end&lt;br /&gt;
          end&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      next_due_date = AssignmentDueDate.find_by(['parent_id = ? &amp;amp;&amp;amp; due_at &amp;gt;= ?', assignment_id, Time.zone.now])&lt;br /&gt;
    end&lt;br /&gt;
    next_due_date&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So this is issue is resolved by the state of the system itself.&amp;lt;br&amp;gt;&lt;br /&gt;
'''''BUT Surprisingly on beta branch Reviewers aren't getting any emails at all'''''&lt;br /&gt;
on beta branch, in submitted_content_controller, in function &amp;quot;submit_file&amp;quot;, this lines is supposed to send email to the reviewers to notify them about the new submission&lt;br /&gt;
&amp;lt;pre&amp;gt; participant.assignment.email(participant.id) rescue nil &amp;lt;/pre&amp;gt;&lt;br /&gt;
''BUT'' here email function is undefined. we checked for email function in assignment class, there was none. The error &amp;quot;undefined function on assignment&amp;quot; is always rescued and hence no errors were raised previously and hence it wasn't highlighted before. &amp;lt;br&amp;gt;&lt;br /&gt;
So, in beta branch reviewers are not being notified anytime a new submission is made to an assignment that they have previously reviewed. So we fixed that&lt;br /&gt;
Taking inspiration from the Master branch the previous team's work we added following code to send an email notifying the reviewer of an new submission.&lt;br /&gt;
&lt;br /&gt;
in submitted_content_controller.rb, in the functions, submit_file, submit_hyperlink&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Team.mail_assigned_reviewers(@participant)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
participant.rb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def mail_assigned_reviewers()&lt;br /&gt;
    team = self.team&lt;br /&gt;
    maps = ResponseMap.where(reviewed_object_id: self.assignment.id, reviewee_id: team.id, type: 'ReviewResponseMap')&lt;br /&gt;
    unless maps.nil?&lt;br /&gt;
      maps.each do |map|&lt;br /&gt;
        reviewer = User.find(Participant.find(map.reviewer_id).user_id)&lt;br /&gt;
        Mailer.sync_message(&lt;br /&gt;
            {&lt;br /&gt;
                :to =&amp;gt; reviewer.email,&lt;br /&gt;
                subject:  &amp;quot;Assignment '#{self.assignment.name}': A submission has been updated since you last reviewed it&amp;quot;,&lt;br /&gt;
                cc: User.find_by(self.assignment.instructor_id).email,&lt;br /&gt;
                :body =&amp;gt; {&lt;br /&gt;
                    :obj_name =&amp;gt; self.assignment.name,&lt;br /&gt;
                    :link =&amp;gt; &amp;quot;https://expertiza.ncsu.edu/response/new?id=#{map.id}&amp;quot;,&lt;br /&gt;
                    :type =&amp;gt; 'submission',&lt;br /&gt;
                    :first_name =&amp;gt; ApplicationHelper::get_user_first_name(User.find(Participant.find(map.reviewer_id).user_id)),&lt;br /&gt;
                    :partial_name =&amp;gt; 'updated_submission_since_review'&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
        ).deliver_now&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
app/views/mailer/partials/_updated_submission_since_review_plain.html.erb&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Hi &amp;lt;%= @first_name %&amp;gt;,&lt;br /&gt;
&lt;br /&gt;
A &amp;lt;%=@type%&amp;gt; you were reviewing for Assignment '&amp;lt;%= @obj_name %&amp;gt;' has been updated since you last review.&lt;br /&gt;
Hence, to update your review please click on the following link.&lt;br /&gt;
&amp;lt;% if @link != nil %&amp;gt;&amp;lt;%= @link %&amp;gt;&amp;lt;% end %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
app/views/mailer/partials/_updated_submission_since_review_html.html.erb&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Hi &amp;lt;%= @first_name %&amp;gt;,&amp;lt;/br&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
  A &amp;lt;%=@type%&amp;gt; you were reviewing for Assignment '&amp;lt;%= @obj_name %&amp;gt;' has been updated since you last review.&amp;lt;br&amp;gt;&lt;br /&gt;
  Hence, to update your review please click on the following link.&amp;lt;br&amp;gt;&lt;br /&gt;
  &amp;lt;% if @link != nil %&amp;gt;&amp;lt;a href=&amp;quot;&amp;lt;%= @link %&amp;gt;&amp;quot;&amp;gt;&amp;lt;%= @link %&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;% end %&amp;gt;&lt;br /&gt;
&amp;lt;/p&amp;gt;  &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
added a line in app/mailers/mailer.rb &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 @link = defn[:body][:link]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
'''Testing Reviewe's Email manually'''&lt;br /&gt;
&lt;br /&gt;
Step 1: Create new assignment [Manage --&amp;gt; Assignment --&amp;gt; + Button (to create new assignment)]&lt;br /&gt;
&lt;br /&gt;
Step 2: Fill the details for the assignments.&lt;br /&gt;
&lt;br /&gt;
Step 3: Navigate to due dates.&lt;br /&gt;
&lt;br /&gt;
Step 4: Change the number of review rounds to 2.&lt;br /&gt;
&lt;br /&gt;
Step 5: Select &amp;quot;Yes&amp;quot; in the dropdown for review allowed during submission and select &amp;quot;Yes&amp;quot; for submission during the review.&lt;br /&gt;
&lt;br /&gt;
Step 6: Add two users to the assignment(author and reviewer).&lt;br /&gt;
&lt;br /&gt;
Step 7: Log in with some user credentials (author credential).&lt;br /&gt;
&lt;br /&gt;
Step 8: Make a new submission to this assignment.&lt;br /&gt;
&lt;br /&gt;
Step 9: Log in with another user (reviewer).&lt;br /&gt;
&lt;br /&gt;
Step 10: Submit a review of the assignment submission.&lt;br /&gt;
&lt;br /&gt;
Step 11: Login as an author again. &lt;br /&gt;
&lt;br /&gt;
Step 12: Edit the submission.&lt;br /&gt;
&lt;br /&gt;
Step 13: After this check the mailbox of the reviewer [development mail for development].&lt;br /&gt;
&lt;br /&gt;
Step 14: Reviewer should get the mail to re-review the work.&lt;br /&gt;
&lt;br /&gt;
Step 15: Change the due date to some date and time which has passed.&lt;br /&gt;
&lt;br /&gt;
Step 16: Now the author should not be able to make a new submission.&lt;br /&gt;
&lt;br /&gt;
'''Testing Reviewe's Email via rspec'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Brief Introduction==&lt;br /&gt;
&lt;br /&gt;
* E2142. Improve e-mail notifications&lt;br /&gt;
* The forked repository can be found at: https://github.com/griffinbrookshire/expertiza&lt;/div&gt;</summary>
		<author><name>Ajulka</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2142._Improve_e-mail_notifications&amp;diff=139207</id>
		<title>CSC/ECE 517 Fall 2021 - E2142. Improve e-mail notifications</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2142._Improve_e-mail_notifications&amp;diff=139207"/>
		<updated>2021-10-19T21:25:37Z</updated>

		<summary type="html">&lt;p&gt;Ajulka: /* E2142. Improve e-mail notifications */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E2142. Improve e-mail notifications=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Work in progress==&lt;br /&gt;
This project is ongoing, and this page will be updated live.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Issue - Don't send email to reviewers for a new submission after the review deadline has passed ==&lt;br /&gt;
&lt;br /&gt;
'''Pre conditions'''&lt;br /&gt;
* There is an assignment, a student as a participant, a participant as a reviewer who is reviewing the this particular assignment&lt;br /&gt;
* a review is made for a submission by the student&lt;br /&gt;
* review deadline has passed&lt;br /&gt;
* the student is allowed to submit after the review deadline has passed&lt;br /&gt;
&lt;br /&gt;
'''Expected Behavior'''&lt;br /&gt;
&lt;br /&gt;
Exact issue stating the expected behavior can be found at https://github.com/expertiza/expertiza/issues/345 - &lt;br /&gt;
&amp;quot;Evidently, if a submission is revised after review, the system e-mails the reviewer saying to revise the review. This is just fine ... except if the last round of review has been completed.&lt;br /&gt;
The message telling reviewers to revise their reviews should not be sent after the last review deadline has passed.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
So basically, When the student makes a new submission after the LAST review deadline has passed. The reviewer should not receive an email, asking the reviewer to update the review according to the new submission.&lt;br /&gt;
&lt;br /&gt;
'''Actual Behavior'''&lt;br /&gt;
&lt;br /&gt;
According to the current Code scenario on the beta branch '''''if the deadline has passed, a student(participant) cannot make new submissions'''''. So, automatically if the participant doe not make a new submission then the reviewer wont receive an email. So this issue does not really exist by the virtue of the state of the system.&lt;br /&gt;
the stack trace for the check if the submission is allowed or not is as follows - &lt;br /&gt;
assignment.rb&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def submission_allowed(topic_id = nil)&lt;br /&gt;
    check_condition('submission_allowed_id', topic_id)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
assignment.rb&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def check_condition(column, topic_id = nil)&lt;br /&gt;
    next_due_date = DueDate.get_next_due_date(self.id, topic_id)&lt;br /&gt;
    return false if next_due_date.nil?&lt;br /&gt;
    right_id = next_due_date.send column&lt;br /&gt;
    right = DeadlineRight.find(right_id)&lt;br /&gt;
    right &amp;amp;&amp;amp; (right.name == 'OK' || right.name == 'Late')&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
due_date.rb&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    def self.get_next_due_date(assignment_id, topic_id = nil)&lt;br /&gt;
    if Assignment.find(assignment_id).staggered_deadline?&lt;br /&gt;
      next_due_date = TopicDueDate.find_by(['parent_id = ? and due_at &amp;gt;= ?', topic_id, Time.zone.now])&lt;br /&gt;
      # if certion TopicDueDate is not exist, we should query next corresponding AssignmentDueDate.&lt;br /&gt;
      # eg. Time.now is 08/28/2016&lt;br /&gt;
      # One topic uses following deadlines:&lt;br /&gt;
      # TopicDueDate      08/01/2016&lt;br /&gt;
      # TopicDueDate      08/02/2016&lt;br /&gt;
      # TopicDueDate      08/03/2016&lt;br /&gt;
      # AssignmentDueDate 09/04/2016&lt;br /&gt;
      # In this case, we cannot find due_at later than Time.now in TopicDueDate.&lt;br /&gt;
      # So we should find next corrsponding AssignmentDueDate, starting with the 4th one, not the 1st one!&lt;br /&gt;
      if next_due_date.nil?&lt;br /&gt;
        topic_due_date_size = TopicDueDate.where(parent_id: topic_id).size&lt;br /&gt;
        following_assignment_due_dates = AssignmentDueDate.where(parent_id: assignment_id)[topic_due_date_size..-1]&lt;br /&gt;
        unless following_assignment_due_dates.nil?&lt;br /&gt;
          following_assignment_due_dates.each do |assignment_due_date|&lt;br /&gt;
            if assignment_due_date.due_at &amp;gt;= Time.zone.now&lt;br /&gt;
              next_due_date = assignment_due_date&lt;br /&gt;
              break&lt;br /&gt;
            end&lt;br /&gt;
          end&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      next_due_date = AssignmentDueDate.find_by(['parent_id = ? &amp;amp;&amp;amp; due_at &amp;gt;= ?', assignment_id, Time.zone.now])&lt;br /&gt;
    end&lt;br /&gt;
    next_due_date&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So this is issue is resolved by the state of the system itself.&amp;lt;br&amp;gt;&lt;br /&gt;
'''''BUT Surprisingly on beta branch Reviewers aren't getting any emails at all'''''&lt;br /&gt;
on beta branch, in submitted_content_controller, in function &amp;quot;submit_file&amp;quot;, this lines is supposed to send email to the reviewers to notify them about the new submission&lt;br /&gt;
&amp;lt;pre&amp;gt; participant.assignment.email(participant.id) rescue nil &amp;lt;/pre&amp;gt;&lt;br /&gt;
''BUT'' here email function is undefined. we checked for email function in assignment class, there was none. The error &amp;quot;undefined function on assignment&amp;quot; is always rescued and hence no errors were raised previously and hence it wasn't highlighted before. &amp;lt;br&amp;gt;&lt;br /&gt;
So, in beta branch reviewers are not being notified anytime a new submission is made to an assignment that they have previously reviewed. So we fixed that&lt;br /&gt;
Taking inspiration from the Master branch the previous team's work we added following code to send an email notifying the reviewer of an new submission.&lt;br /&gt;
&lt;br /&gt;
in submitted_content_controller.rb, in the functions, submit_file, submit_hyperlink&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Team.mail_assigned_reviewers(@participant)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
team.rb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def self.mail_assigned_reviewers(participant)&lt;br /&gt;
    team = participant.team&lt;br /&gt;
    maps = ResponseMap.where(reviewed_object_id: participant.assignment.id, reviewee_id: team.id, type: 'ReviewResponseMap')&lt;br /&gt;
    unless maps.nil?&lt;br /&gt;
      maps.each do |map|&lt;br /&gt;
        reviewer = User.find(Participant.find(map.reviewer_id).user_id)&lt;br /&gt;
        Mailer.sync_message(&lt;br /&gt;
            {&lt;br /&gt;
                :to =&amp;gt; reviewer.email,&lt;br /&gt;
                subject:  &amp;quot;Assignment '#{participant.assignment.name}': A submission has been updated since you last reviewed it&amp;quot;,&lt;br /&gt;
                cc: User.find_by(participant.assignment.instructor_id).email,&lt;br /&gt;
                :body =&amp;gt; {&lt;br /&gt;
                    :obj_name =&amp;gt; participant.assignment.name,&lt;br /&gt;
                    :link =&amp;gt; &amp;quot;https://expertiza.ncsu.edu/response/new?id=#{map.id}&amp;quot;,&lt;br /&gt;
                    :type =&amp;gt; 'submission',&lt;br /&gt;
                    :first_name =&amp;gt; ApplicationHelper::get_user_first_name(User.find(Participant.find(map.reviewer_id).user_id)),&lt;br /&gt;
                    :partial_name =&amp;gt; 'updated_submission_since_review'&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
        ).deliver_now&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
app/views/mailer/partials/_updated_submission_since_review_plain.html.erb&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Hi &amp;lt;%= @first_name %&amp;gt;,&lt;br /&gt;
&lt;br /&gt;
A &amp;lt;%=@type%&amp;gt; you were reviewing for Assignment '&amp;lt;%= @obj_name %&amp;gt;' has been updated since you last review.&lt;br /&gt;
Hence, to update your review please click on the following link.&lt;br /&gt;
&amp;lt;% if @link != nil %&amp;gt;&amp;lt;%= @link %&amp;gt;&amp;lt;% end %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
app/views/mailer/partials/_updated_submission_since_review_html.html.erb&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Hi &amp;lt;%= @first_name %&amp;gt;,&amp;lt;/br&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
  A &amp;lt;%=@type%&amp;gt; you were reviewing for Assignment '&amp;lt;%= @obj_name %&amp;gt;' has been updated since you last review.&amp;lt;br&amp;gt;&lt;br /&gt;
  Hence, to update your review please click on the following link.&amp;lt;br&amp;gt;&lt;br /&gt;
  &amp;lt;% if @link != nil %&amp;gt;&amp;lt;a href=&amp;quot;&amp;lt;%= @link %&amp;gt;&amp;quot;&amp;gt;&amp;lt;%= @link %&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;% end %&amp;gt;&lt;br /&gt;
&amp;lt;/p&amp;gt;  &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
added a line in app/mailers/mailer.rb &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 @link = defn[:body][:link]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
'''Testing Reviewe's Email manually'''&lt;br /&gt;
&lt;br /&gt;
Step 1: Create new assignment [Manage --&amp;gt; Assignment --&amp;gt; + Button (to create new assignment)]&lt;br /&gt;
&lt;br /&gt;
Step 2: Fill the details for the assignments.&lt;br /&gt;
&lt;br /&gt;
Step 3: Navigate to due dates.&lt;br /&gt;
&lt;br /&gt;
Step 4: Change the number of review rounds to 2.&lt;br /&gt;
&lt;br /&gt;
Step 5: Select &amp;quot;Yes&amp;quot; in the dropdown for review allowed during submission and select &amp;quot;Yes&amp;quot; for submission during the review.&lt;br /&gt;
&lt;br /&gt;
Step 6: Add two users to the assignment(author and reviewer).&lt;br /&gt;
&lt;br /&gt;
Step 7: Log in with some user credentials (author credential).&lt;br /&gt;
&lt;br /&gt;
Step 8: Make a new submission to this assignment.&lt;br /&gt;
&lt;br /&gt;
Step 9: Log in with another user (reviewer).&lt;br /&gt;
&lt;br /&gt;
Step 10: Submit a review of the assignment submission.&lt;br /&gt;
&lt;br /&gt;
Step 11: Login as an author again. &lt;br /&gt;
&lt;br /&gt;
Step 12: Edit the submission.&lt;br /&gt;
&lt;br /&gt;
Step 13: After this check the mailbox of the reviewer [development mail for development].&lt;br /&gt;
&lt;br /&gt;
Step 14: Reviewer should get the mail to re-review the work.&lt;br /&gt;
&lt;br /&gt;
Step 15: Change the due date to some date and time which has passed.&lt;br /&gt;
&lt;br /&gt;
Step 16: Now the author should not be able to make a new submission.&lt;br /&gt;
&lt;br /&gt;
'''Testing Reviewe's Email via rspec'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Brief Introduction==&lt;br /&gt;
&lt;br /&gt;
* E2142. Improve e-mail notifications&lt;br /&gt;
* The forked repository can be found at: https://github.com/griffinbrookshire/expertiza&lt;/div&gt;</summary>
		<author><name>Ajulka</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2142._Improve_e-mail_notifications&amp;diff=139206</id>
		<title>CSC/ECE 517 Fall 2021 - E2142. Improve e-mail notifications</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2142._Improve_e-mail_notifications&amp;diff=139206"/>
		<updated>2021-10-19T21:22:31Z</updated>

		<summary type="html">&lt;p&gt;Ajulka: /* Issue - Don't send email to reviewers for a new submission after the review deadline has passed */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E2142. Improve e-mail notifications=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Work in progress==&lt;br /&gt;
This project is ongoing, and this page will be updated live.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Issue - Don't send email to reviewers for a new submission after the review deadline has passed ==&lt;br /&gt;
&lt;br /&gt;
'''Pre conditions'''&lt;br /&gt;
* There is an assignment, a student as a participant, a participant as a reviewer who is reviewing the this particular assignment&lt;br /&gt;
* a review is made for a submission by the student&lt;br /&gt;
* review deadline has passed&lt;br /&gt;
* the student is allowed to submit after the review deadline has passed&lt;br /&gt;
&lt;br /&gt;
'''Expected Behavior'''&lt;br /&gt;
&lt;br /&gt;
Exact issue stating the expected behavior can be found at https://github.com/expertiza/expertiza/issues/345 - &lt;br /&gt;
&amp;quot;Evidently, if a submission is revised after review, the system e-mails the reviewer saying to revise the review. This is just fine ... except if the last round of review has been completed.&lt;br /&gt;
The message telling reviewers to revise their reviews should not be sent after the last review deadline has passed.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
So basically, When the student makes a new submission after the LAST review deadline has passed. The reviewer should not receive an email, asking the reviewer to update the review according to the new submission.&lt;br /&gt;
&lt;br /&gt;
'''Actual Behavior'''&lt;br /&gt;
&lt;br /&gt;
According to the current Code scenario on the beta branch '''''if the deadline has passed, a student(participant) cannot make new submissions'''''. So, automatically if the participant doe not make a new submission then the reviewer wont receive an email. So this issue does not really exist by the virtue of the state of the system.&lt;br /&gt;
the stack trace for the check if the submission is allowed or not is as follows - &lt;br /&gt;
assignment.rb&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def submission_allowed(topic_id = nil)&lt;br /&gt;
    check_condition('submission_allowed_id', topic_id)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
assignment.rb&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def check_condition(column, topic_id = nil)&lt;br /&gt;
    next_due_date = DueDate.get_next_due_date(self.id, topic_id)&lt;br /&gt;
    return false if next_due_date.nil?&lt;br /&gt;
    right_id = next_due_date.send column&lt;br /&gt;
    right = DeadlineRight.find(right_id)&lt;br /&gt;
    right &amp;amp;&amp;amp; (right.name == 'OK' || right.name == 'Late')&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
due_date.rb&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    def self.get_next_due_date(assignment_id, topic_id = nil)&lt;br /&gt;
    if Assignment.find(assignment_id).staggered_deadline?&lt;br /&gt;
      next_due_date = TopicDueDate.find_by(['parent_id = ? and due_at &amp;gt;= ?', topic_id, Time.zone.now])&lt;br /&gt;
      # if certion TopicDueDate is not exist, we should query next corresponding AssignmentDueDate.&lt;br /&gt;
      # eg. Time.now is 08/28/2016&lt;br /&gt;
      # One topic uses following deadlines:&lt;br /&gt;
      # TopicDueDate      08/01/2016&lt;br /&gt;
      # TopicDueDate      08/02/2016&lt;br /&gt;
      # TopicDueDate      08/03/2016&lt;br /&gt;
      # AssignmentDueDate 09/04/2016&lt;br /&gt;
      # In this case, we cannot find due_at later than Time.now in TopicDueDate.&lt;br /&gt;
      # So we should find next corrsponding AssignmentDueDate, starting with the 4th one, not the 1st one!&lt;br /&gt;
      if next_due_date.nil?&lt;br /&gt;
        topic_due_date_size = TopicDueDate.where(parent_id: topic_id).size&lt;br /&gt;
        following_assignment_due_dates = AssignmentDueDate.where(parent_id: assignment_id)[topic_due_date_size..-1]&lt;br /&gt;
        unless following_assignment_due_dates.nil?&lt;br /&gt;
          following_assignment_due_dates.each do |assignment_due_date|&lt;br /&gt;
            if assignment_due_date.due_at &amp;gt;= Time.zone.now&lt;br /&gt;
              next_due_date = assignment_due_date&lt;br /&gt;
              break&lt;br /&gt;
            end&lt;br /&gt;
          end&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      next_due_date = AssignmentDueDate.find_by(['parent_id = ? &amp;amp;&amp;amp; due_at &amp;gt;= ?', assignment_id, Time.zone.now])&lt;br /&gt;
    end&lt;br /&gt;
    next_due_date&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So this is issue is resolved by the state of the system itself.&amp;lt;br&amp;gt;&lt;br /&gt;
'''''BUT Surprisingly on beta branch Reviewers aren't getting any emails at all'''''&lt;br /&gt;
on beta branch, in submitted_content_controller, in function &amp;quot;submit_file&amp;quot;, this lines is supposed to send email to the reviewers to notify them about the new submission&lt;br /&gt;
&amp;lt;pre&amp;gt; participant.assignment.email(participant.id) rescue nil &amp;lt;/pre&amp;gt;&lt;br /&gt;
''BUT'' here email function is undefined. we checked for email function in assignment class, there was none. The error &amp;quot;undefined function on assignment&amp;quot; is always rescued and hence no errors were raised previously and hence it wasn't highlighted before. &amp;lt;br&amp;gt;&lt;br /&gt;
So, in beta branch reviewers are not being notified anytime a new submission is made to an assignment that they have previously reviewed. So we fixed that&lt;br /&gt;
Taking inspiration from the Master branch the previous team's work we added following code to send an email notifying the reviewer of an new submission.&lt;br /&gt;
&lt;br /&gt;
in submitted_content_controller.rb, in the functions, submit_file, submit_hyperlink&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Team.mail_assigned_reviewers(@participant)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
team.rb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def self.mail_assigned_reviewers(participant)&lt;br /&gt;
    team = participant.team&lt;br /&gt;
    maps = ResponseMap.where(reviewed_object_id: participant.assignment.id, reviewee_id: team.id, type: 'ReviewResponseMap')&lt;br /&gt;
    unless maps.nil?&lt;br /&gt;
      maps.each do |map|&lt;br /&gt;
        reviewer = User.find(Participant.find(map.reviewer_id).user_id)&lt;br /&gt;
        Mailer.sync_message(&lt;br /&gt;
            {&lt;br /&gt;
                :to =&amp;gt; reviewer.email,&lt;br /&gt;
                subject:  &amp;quot;Assignment '#{participant.assignment.name}': A submission has been updated since you last reviewed it&amp;quot;,&lt;br /&gt;
                cc: User.find_by(participant.assignment.instructor_id).email,&lt;br /&gt;
                :body =&amp;gt; {&lt;br /&gt;
                    :obj_name =&amp;gt; participant.assignment.name,&lt;br /&gt;
                    :link =&amp;gt; &amp;quot;https://expertiza.ncsu.edu/response/new?id=#{map.id}&amp;quot;,&lt;br /&gt;
                    :type =&amp;gt; 'submission',&lt;br /&gt;
                    :first_name =&amp;gt; ApplicationHelper::get_user_first_name(User.find(Participant.find(map.reviewer_id).user_id)),&lt;br /&gt;
                    :partial_name =&amp;gt; 'updated_submission_since_review'&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
        ).deliver_now&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
app/views/mailer/partials/_updated_submission_since_review_plain.html.erb&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Hi &amp;lt;%= @first_name %&amp;gt;,&lt;br /&gt;
&lt;br /&gt;
A &amp;lt;%=@type%&amp;gt; you were reviewing for Assignment '&amp;lt;%= @obj_name %&amp;gt;' has been updated since you last review.&lt;br /&gt;
Hence, to update your review please click on the following link.&lt;br /&gt;
&amp;lt;% if @link != nil %&amp;gt;&amp;lt;%= @link %&amp;gt;&amp;lt;% end %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
app/views/mailer/partials/_updated_submission_since_review_html.html.erb&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Hi &amp;lt;%= @first_name %&amp;gt;,&amp;lt;/br&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
  A &amp;lt;%=@type%&amp;gt; you were reviewing for Assignment '&amp;lt;%= @obj_name %&amp;gt;' has been updated since you last review.&amp;lt;br&amp;gt;&lt;br /&gt;
  Hence, to update your review please click on the following link.&amp;lt;br&amp;gt;&lt;br /&gt;
  &amp;lt;% if @link != nil %&amp;gt;&amp;lt;a href=&amp;quot;&amp;lt;%= @link %&amp;gt;&amp;quot;&amp;gt;&amp;lt;%= @link %&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;% end %&amp;gt;&lt;br /&gt;
&amp;lt;/p&amp;gt;  &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
added a line in app/mailers/mailer.rb &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 @link = defn[:body][:link]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Brief Introduction==&lt;br /&gt;
&lt;br /&gt;
* E2142. Improve e-mail notifications&lt;br /&gt;
* The forked repository can be found at: https://github.com/griffinbrookshire/expertiza&lt;/div&gt;</summary>
		<author><name>Ajulka</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2142._Improve_e-mail_notifications&amp;diff=139205</id>
		<title>CSC/ECE 517 Fall 2021 - E2142. Improve e-mail notifications</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2142._Improve_e-mail_notifications&amp;diff=139205"/>
		<updated>2021-10-19T21:04:53Z</updated>

		<summary type="html">&lt;p&gt;Ajulka: /* Issue - Don't send email to reviewers for a new submission after the review deadline has passed */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E2142. Improve e-mail notifications=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Work in progress==&lt;br /&gt;
This project is ongoing, and this page will be updated live.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Issue - Don't send email to reviewers for a new submission after the review deadline has passed ==&lt;br /&gt;
&lt;br /&gt;
'''Pre conditions'''&lt;br /&gt;
* There is an assignment, a student as a participant, a participant as a reviewer who is reviewing the this particular assignment&lt;br /&gt;
* a review is made for a submission by the student&lt;br /&gt;
* review deadline has passed&lt;br /&gt;
* the student is allowed to submit after the review deadline has passed&lt;br /&gt;
&lt;br /&gt;
'''Expected Behavior'''&lt;br /&gt;
&lt;br /&gt;
Exact issue stating the expected behavior can be found at https://github.com/expertiza/expertiza/issues/345 - &lt;br /&gt;
&amp;quot;Evidently, if a submission is revised after review, the system e-mails the reviewer saying to revise the review. This is just fine ... except if the last round of review has been completed.&lt;br /&gt;
The message telling reviewers to revise their reviews should not be sent after the last review deadline has passed.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
So basically, When the student makes a new submission after the LAST review deadline has passed. The reviewer should not receive an email, asking the reviewer to update the review according to the new submission.&lt;br /&gt;
&lt;br /&gt;
'''Actual Behavior'''&lt;br /&gt;
&lt;br /&gt;
According to the current Code scenario on the beta branch '''''if the deadline has passed, a student(participant) cannot make new submissions'''''. So, automatically if the participant doe not make a new submission then the reviewer wont receive an email. So this issue does not really exist by the virtue of the state of the system.&lt;br /&gt;
the stack trace for the check if the submission is allowed or not is as follows - &lt;br /&gt;
assignment.rb&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def submission_allowed(topic_id = nil)&lt;br /&gt;
    check_condition('submission_allowed_id', topic_id)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
assignment.rb&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def check_condition(column, topic_id = nil)&lt;br /&gt;
    next_due_date = DueDate.get_next_due_date(self.id, topic_id)&lt;br /&gt;
    return false if next_due_date.nil?&lt;br /&gt;
    right_id = next_due_date.send column&lt;br /&gt;
    right = DeadlineRight.find(right_id)&lt;br /&gt;
    right &amp;amp;&amp;amp; (right.name == 'OK' || right.name == 'Late')&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
due_date.rb&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    def self.get_next_due_date(assignment_id, topic_id = nil)&lt;br /&gt;
    if Assignment.find(assignment_id).staggered_deadline?&lt;br /&gt;
      next_due_date = TopicDueDate.find_by(['parent_id = ? and due_at &amp;gt;= ?', topic_id, Time.zone.now])&lt;br /&gt;
      # if certion TopicDueDate is not exist, we should query next corresponding AssignmentDueDate.&lt;br /&gt;
      # eg. Time.now is 08/28/2016&lt;br /&gt;
      # One topic uses following deadlines:&lt;br /&gt;
      # TopicDueDate      08/01/2016&lt;br /&gt;
      # TopicDueDate      08/02/2016&lt;br /&gt;
      # TopicDueDate      08/03/2016&lt;br /&gt;
      # AssignmentDueDate 09/04/2016&lt;br /&gt;
      # In this case, we cannot find due_at later than Time.now in TopicDueDate.&lt;br /&gt;
      # So we should find next corrsponding AssignmentDueDate, starting with the 4th one, not the 1st one!&lt;br /&gt;
      if next_due_date.nil?&lt;br /&gt;
        topic_due_date_size = TopicDueDate.where(parent_id: topic_id).size&lt;br /&gt;
        following_assignment_due_dates = AssignmentDueDate.where(parent_id: assignment_id)[topic_due_date_size..-1]&lt;br /&gt;
        unless following_assignment_due_dates.nil?&lt;br /&gt;
          following_assignment_due_dates.each do |assignment_due_date|&lt;br /&gt;
            if assignment_due_date.due_at &amp;gt;= Time.zone.now&lt;br /&gt;
              next_due_date = assignment_due_date&lt;br /&gt;
              break&lt;br /&gt;
            end&lt;br /&gt;
          end&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      next_due_date = AssignmentDueDate.find_by(['parent_id = ? &amp;amp;&amp;amp; due_at &amp;gt;= ?', assignment_id, Time.zone.now])&lt;br /&gt;
    end&lt;br /&gt;
    next_due_date&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So this is issue is resolved by the state of the system itself.&amp;lt;br&amp;gt;&lt;br /&gt;
'''''BUT Surprisingly on beta branch Reviewers aren't getting any emails at all'''''&lt;br /&gt;
on beta branch, in submitted_content_controller, in function &amp;quot;submit_file&amp;quot;, this lines is supposed to send email to the reviewers to notify them about the new submission&lt;br /&gt;
&amp;lt;pre&amp;gt; participant.assignment.email(participant.id) rescue nil &amp;lt;/pre&amp;gt;&lt;br /&gt;
''BUT'' here email function is undefined. we checked for email function in assignment class, there was none. The error &amp;quot;undefined function on assignment&amp;quot; is always rescued and hence no errors were raised previously and hence it wasn't highlighted before. &amp;lt;br&amp;gt;&lt;br /&gt;
So, in beta branch reviewers are not being notified anytime a new submission is made to an assignment that they have previously reviewed. So we fixed that&lt;br /&gt;
Taking inspiration from the Master branch the previous team's work we added following code to send an email notifying the reviewer of an new submission.&lt;br /&gt;
&lt;br /&gt;
in submitted_content_controller.rb, in the functions, submit_file, submit_hyperlink&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Team.mail_assigned_reviewers(@participant)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
team.rb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def self.mail_assigned_reviewers(participant)&lt;br /&gt;
    team = participant.team&lt;br /&gt;
    maps = ResponseMap.where(reviewed_object_id: participant.assignment.id, reviewee_id: team.id, type: 'ReviewResponseMap')&lt;br /&gt;
    unless maps.nil?&lt;br /&gt;
      maps.each do |map|&lt;br /&gt;
        reviewer = User.find(Participant.find(map.reviewer_id).user_id)&lt;br /&gt;
        Mailer.sync_message(&lt;br /&gt;
            {&lt;br /&gt;
                :to =&amp;gt; reviewer.email,&lt;br /&gt;
                subject:  &amp;quot;Assignment '#{participant.assignment.name}': A submission has been updated since you last reviewed it&amp;quot;,&lt;br /&gt;
                cc: User.find_by(participant.assignment.instructor_id).email,&lt;br /&gt;
                :body =&amp;gt; {&lt;br /&gt;
                    :obj_name =&amp;gt; participant.assignment.name,&lt;br /&gt;
                    :link =&amp;gt; &amp;quot;https://expertiza.ncsu.edu/response/new?id=#{map.id}&amp;quot;,&lt;br /&gt;
                    :type =&amp;gt; 'submission',&lt;br /&gt;
                    :first_name =&amp;gt; ApplicationHelper::get_user_first_name(User.find(Participant.find(map.reviewer_id).user_id)),&lt;br /&gt;
                    :partial_name =&amp;gt; 'updated_submission_since_review'&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
        ).deliver_now&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Brief Introduction==&lt;br /&gt;
&lt;br /&gt;
* E2142. Improve e-mail notifications&lt;br /&gt;
* The forked repository can be found at: https://github.com/griffinbrookshire/expertiza&lt;/div&gt;</summary>
		<author><name>Ajulka</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2142._Improve_e-mail_notifications&amp;diff=139204</id>
		<title>CSC/ECE 517 Fall 2021 - E2142. Improve e-mail notifications</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2142._Improve_e-mail_notifications&amp;diff=139204"/>
		<updated>2021-10-19T20:57:52Z</updated>

		<summary type="html">&lt;p&gt;Ajulka: /* Issue - Don't send email to reviewers for a new submission after the review deadline has passed */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E2142. Improve e-mail notifications=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Work in progress==&lt;br /&gt;
This project is ongoing, and this page will be updated live.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Issue - Don't send email to reviewers for a new submission after the review deadline has passed ==&lt;br /&gt;
&lt;br /&gt;
'''Pre conditions'''&lt;br /&gt;
- There is an assignment, a student as a participant, a participant as a reviewer who is reviewing the this particular assignment&lt;br /&gt;
- a review is made for a submission by the student&lt;br /&gt;
- review deadline has passed&lt;br /&gt;
- the student is allowed to submit after the review deadline has passed&lt;br /&gt;
&lt;br /&gt;
'''Expected Behavior'''&lt;br /&gt;
&lt;br /&gt;
Exact issue stating the expected behavior can be found at https://github.com/expertiza/expertiza/issues/345 - &lt;br /&gt;
&amp;quot;Evidently, if a submission is revised after review, the system e-mails the reviewer saying to revise the review. This is just fine ... except if the last round of review has been completed.&lt;br /&gt;
The message telling reviewers to revise their reviews should not be sent after the last review deadline has passed.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
So basically, When the student makes a new submission after the LAST review deadline has passed. The reviewer should not receive an email, asking the reviewer to update the review according to the new submission.&lt;br /&gt;
&lt;br /&gt;
'''Actual Behavior'''&lt;br /&gt;
&lt;br /&gt;
According to the current Code scenario on the beta branch '''''if the deadline has passed, a student(participant) cannot make new submissions'''''. So, automatically if the participant doe not make a new submission then the reviewer wont receive an email. So this issue does not really exist by the virtue of the state of the system.&lt;br /&gt;
the stack trace for the check if the submission is allowed or not is as follows - &lt;br /&gt;
assignment.rb&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def submission_allowed(topic_id = nil)&lt;br /&gt;
    check_condition('submission_allowed_id', topic_id)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
assignment.rb&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def check_condition(column, topic_id = nil)&lt;br /&gt;
    next_due_date = DueDate.get_next_due_date(self.id, topic_id)&lt;br /&gt;
    return false if next_due_date.nil?&lt;br /&gt;
    right_id = next_due_date.send column&lt;br /&gt;
    right = DeadlineRight.find(right_id)&lt;br /&gt;
    right &amp;amp;&amp;amp; (right.name == 'OK' || right.name == 'Late')&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
due_date.rb&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    def self.get_next_due_date(assignment_id, topic_id = nil)&lt;br /&gt;
    if Assignment.find(assignment_id).staggered_deadline?&lt;br /&gt;
      next_due_date = TopicDueDate.find_by(['parent_id = ? and due_at &amp;gt;= ?', topic_id, Time.zone.now])&lt;br /&gt;
      # if certion TopicDueDate is not exist, we should query next corresponding AssignmentDueDate.&lt;br /&gt;
      # eg. Time.now is 08/28/2016&lt;br /&gt;
      # One topic uses following deadlines:&lt;br /&gt;
      # TopicDueDate      08/01/2016&lt;br /&gt;
      # TopicDueDate      08/02/2016&lt;br /&gt;
      # TopicDueDate      08/03/2016&lt;br /&gt;
      # AssignmentDueDate 09/04/2016&lt;br /&gt;
      # In this case, we cannot find due_at later than Time.now in TopicDueDate.&lt;br /&gt;
      # So we should find next corrsponding AssignmentDueDate, starting with the 4th one, not the 1st one!&lt;br /&gt;
      if next_due_date.nil?&lt;br /&gt;
        topic_due_date_size = TopicDueDate.where(parent_id: topic_id).size&lt;br /&gt;
        following_assignment_due_dates = AssignmentDueDate.where(parent_id: assignment_id)[topic_due_date_size..-1]&lt;br /&gt;
        unless following_assignment_due_dates.nil?&lt;br /&gt;
          following_assignment_due_dates.each do |assignment_due_date|&lt;br /&gt;
            if assignment_due_date.due_at &amp;gt;= Time.zone.now&lt;br /&gt;
              next_due_date = assignment_due_date&lt;br /&gt;
              break&lt;br /&gt;
            end&lt;br /&gt;
          end&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      next_due_date = AssignmentDueDate.find_by(['parent_id = ? &amp;amp;&amp;amp; due_at &amp;gt;= ?', assignment_id, Time.zone.now])&lt;br /&gt;
    end&lt;br /&gt;
    next_due_date&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So this is issue is resolved by the state of the system itself.&amp;lt;br&amp;gt;&lt;br /&gt;
'''''BUT Surprisingly on beta branch Reviewers aren't getting any emails at all'''''&lt;br /&gt;
on beta branch, in submitted_content_controller, in function &amp;quot;submit_file&amp;quot;, this lines is supposed to send email to the reviewers to notify them about the new submission&lt;br /&gt;
&amp;lt;pre&amp;gt; participant.assignment.email(participant.id) rescue nil &amp;lt;/pre&amp;gt;&lt;br /&gt;
'''''BUT''''' here email function is undefined. we checked for email function in assignment class, there was none. The error &amp;quot;undefined function on assignment&amp;quot; is always rescued and hence no errors were raised previously and hence it wasn't highlighted before. &amp;lt;br&amp;gt;&lt;br /&gt;
So, in beta branch reviewers are not being notified anytime a new submission is made to an assignment that they have previously reviewed. So we fixed that&lt;br /&gt;
&lt;br /&gt;
==Brief Introduction==&lt;br /&gt;
&lt;br /&gt;
* E2142. Improve e-mail notifications&lt;br /&gt;
* The forked repository can be found at: https://github.com/griffinbrookshire/expertiza&lt;/div&gt;</summary>
		<author><name>Ajulka</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2142._Improve_e-mail_notifications&amp;diff=139203</id>
		<title>CSC/ECE 517 Fall 2021 - E2142. Improve e-mail notifications</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2142._Improve_e-mail_notifications&amp;diff=139203"/>
		<updated>2021-10-19T20:50:28Z</updated>

		<summary type="html">&lt;p&gt;Ajulka: /* Issue - Don't send email to reviewers for a new submission after the review deadline has passed */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E2142. Improve e-mail notifications=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Work in progress==&lt;br /&gt;
This project is ongoing, and this page will be updated live.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Issue - Don't send email to reviewers for a new submission after the review deadline has passed ==&lt;br /&gt;
&lt;br /&gt;
'''Pre conditions'''&lt;br /&gt;
- There is an assignment, a student as a participant, a participant as a reviewer who is reviewing the this particular assignment&lt;br /&gt;
- a review is made for a submission by the student&lt;br /&gt;
- review deadline has passed&lt;br /&gt;
- the student is allowed to submit after the review deadline has passed&lt;br /&gt;
&lt;br /&gt;
'''Expected Behavior'''&lt;br /&gt;
&lt;br /&gt;
Exact issue stating the expected behavior can be found at https://github.com/expertiza/expertiza/issues/345 - &lt;br /&gt;
&amp;quot;Evidently, if a submission is revised after review, the system e-mails the reviewer saying to revise the review. This is just fine ... except if the last round of review has been completed.&lt;br /&gt;
The message telling reviewers to revise their reviews should not be sent after the last review deadline has passed.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
So basically, When the student makes a new submission after the LAST review deadline has passed. The reviewer should not receive an email, asking the reviewer to update the review according to the new submission.&lt;br /&gt;
&lt;br /&gt;
'''Actual Behavior'''&lt;br /&gt;
&lt;br /&gt;
According to the current Code scenario on the beta branch '''''if the deadline has passed, a student(participant) cannot make new submissions'''''. So, automatically if the participant doe not make a new submission then the reviewer wont receive an email. So this issue does not really exist by the virtue of the state of the system.&lt;br /&gt;
the stack trace for the check if the submission is allowed or not is as follows - &lt;br /&gt;
assignment.rb&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def submission_allowed(topic_id = nil)&lt;br /&gt;
    check_condition('submission_allowed_id', topic_id)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
assignment.rb&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def check_condition(column, topic_id = nil)&lt;br /&gt;
    next_due_date = DueDate.get_next_due_date(self.id, topic_id)&lt;br /&gt;
    return false if next_due_date.nil?&lt;br /&gt;
    right_id = next_due_date.send column&lt;br /&gt;
    right = DeadlineRight.find(right_id)&lt;br /&gt;
    right &amp;amp;&amp;amp; (right.name == 'OK' || right.name == 'Late')&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
due_date.rb&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    def self.get_next_due_date(assignment_id, topic_id = nil)&lt;br /&gt;
    if Assignment.find(assignment_id).staggered_deadline?&lt;br /&gt;
      next_due_date = TopicDueDate.find_by(['parent_id = ? and due_at &amp;gt;= ?', topic_id, Time.zone.now])&lt;br /&gt;
      # if certion TopicDueDate is not exist, we should query next corresponding AssignmentDueDate.&lt;br /&gt;
      # eg. Time.now is 08/28/2016&lt;br /&gt;
      # One topic uses following deadlines:&lt;br /&gt;
      # TopicDueDate      08/01/2016&lt;br /&gt;
      # TopicDueDate      08/02/2016&lt;br /&gt;
      # TopicDueDate      08/03/2016&lt;br /&gt;
      # AssignmentDueDate 09/04/2016&lt;br /&gt;
      # In this case, we cannot find due_at later than Time.now in TopicDueDate.&lt;br /&gt;
      # So we should find next corrsponding AssignmentDueDate, starting with the 4th one, not the 1st one!&lt;br /&gt;
      if next_due_date.nil?&lt;br /&gt;
        topic_due_date_size = TopicDueDate.where(parent_id: topic_id).size&lt;br /&gt;
        following_assignment_due_dates = AssignmentDueDate.where(parent_id: assignment_id)[topic_due_date_size..-1]&lt;br /&gt;
        unless following_assignment_due_dates.nil?&lt;br /&gt;
          following_assignment_due_dates.each do |assignment_due_date|&lt;br /&gt;
            if assignment_due_date.due_at &amp;gt;= Time.zone.now&lt;br /&gt;
              next_due_date = assignment_due_date&lt;br /&gt;
              break&lt;br /&gt;
            end&lt;br /&gt;
          end&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      next_due_date = AssignmentDueDate.find_by(['parent_id = ? &amp;amp;&amp;amp; due_at &amp;gt;= ?', assignment_id, Time.zone.now])&lt;br /&gt;
    end&lt;br /&gt;
    next_due_date&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So this is issue is resolved by the state of the system itself.&amp;lt;br&amp;gt;&lt;br /&gt;
'''''BUT Surprisingly on beta branch Reviewers aren't getting any emails at all'''''&lt;br /&gt;
&lt;br /&gt;
==Brief Introduction==&lt;br /&gt;
&lt;br /&gt;
* E2142. Improve e-mail notifications&lt;br /&gt;
* The forked repository can be found at: https://github.com/griffinbrookshire/expertiza&lt;/div&gt;</summary>
		<author><name>Ajulka</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2142._Improve_e-mail_notifications&amp;diff=139202</id>
		<title>CSC/ECE 517 Fall 2021 - E2142. Improve e-mail notifications</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2142._Improve_e-mail_notifications&amp;diff=139202"/>
		<updated>2021-10-19T20:49:39Z</updated>

		<summary type="html">&lt;p&gt;Ajulka: /* Issue - Don't send email to reviewers for a new submission after the review deadline has passed */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E2142. Improve e-mail notifications=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Work in progress==&lt;br /&gt;
This project is ongoing, and this page will be updated live.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Issue - Don't send email to reviewers for a new submission after the review deadline has passed ==&lt;br /&gt;
&lt;br /&gt;
'''Pre conditions'''&lt;br /&gt;
- There is an assignment, a student as a participant, a participant as a reviewer who is reviewing the this particular assignment&lt;br /&gt;
- a review is made for a submission by the student&lt;br /&gt;
- review deadline has passed&lt;br /&gt;
- the student is allowed to submit after the review deadline has passed&lt;br /&gt;
&lt;br /&gt;
'''Expected Behavior'''&lt;br /&gt;
&lt;br /&gt;
Exact issue stating the expected behavior can be found at https://github.com/expertiza/expertiza/issues/345 - &lt;br /&gt;
&amp;quot;Evidently, if a submission is revised after review, the system e-mails the reviewer saying to revise the review. This is just fine ... except if the last round of review has been completed.&lt;br /&gt;
The message telling reviewers to revise their reviews should not be sent after the last review deadline has passed.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
So basically, When the student makes a new submission after the LAST review deadline has passed. The reviewer should not receive an email, asking the reviewer to update the review according to the new submission.&lt;br /&gt;
&lt;br /&gt;
'''Actual Behavior'''&lt;br /&gt;
&lt;br /&gt;
According to the current Code scenario on the beta branch '''''if the deadline has passed, a student(participant) cannot make new submissions'''''. So, automatically if the participant doe not make a new submission then the reviewer wont receive an email. So this issue does not really exist by the virtue of the state of the system.&lt;br /&gt;
the stack trace for the check if the submission is allowed or not is as follows - &lt;br /&gt;
assignment.rb&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def submission_allowed(topic_id = nil)&lt;br /&gt;
    check_condition('submission_allowed_id', topic_id)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
assignment.rb&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def check_condition(column, topic_id = nil)&lt;br /&gt;
    next_due_date = DueDate.get_next_due_date(self.id, topic_id)&lt;br /&gt;
    return false if next_due_date.nil?&lt;br /&gt;
    right_id = next_due_date.send column&lt;br /&gt;
    right = DeadlineRight.find(right_id)&lt;br /&gt;
    right &amp;amp;&amp;amp; (right.name == 'OK' || right.name == 'Late')&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
due_date.rb&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    def self.get_next_due_date(assignment_id, topic_id = nil)&lt;br /&gt;
    if Assignment.find(assignment_id).staggered_deadline?&lt;br /&gt;
      next_due_date = TopicDueDate.find_by(['parent_id = ? and due_at &amp;gt;= ?', topic_id, Time.zone.now])&lt;br /&gt;
      # if certion TopicDueDate is not exist, we should query next corresponding AssignmentDueDate.&lt;br /&gt;
      # eg. Time.now is 08/28/2016&lt;br /&gt;
      # One topic uses following deadlines:&lt;br /&gt;
      # TopicDueDate      08/01/2016&lt;br /&gt;
      # TopicDueDate      08/02/2016&lt;br /&gt;
      # TopicDueDate      08/03/2016&lt;br /&gt;
      # AssignmentDueDate 09/04/2016&lt;br /&gt;
      # In this case, we cannot find due_at later than Time.now in TopicDueDate.&lt;br /&gt;
      # So we should find next corrsponding AssignmentDueDate, starting with the 4th one, not the 1st one!&lt;br /&gt;
      if next_due_date.nil?&lt;br /&gt;
        topic_due_date_size = TopicDueDate.where(parent_id: topic_id).size&lt;br /&gt;
        following_assignment_due_dates = AssignmentDueDate.where(parent_id: assignment_id)[topic_due_date_size..-1]&lt;br /&gt;
        unless following_assignment_due_dates.nil?&lt;br /&gt;
          following_assignment_due_dates.each do |assignment_due_date|&lt;br /&gt;
            if assignment_due_date.due_at &amp;gt;= Time.zone.now&lt;br /&gt;
              next_due_date = assignment_due_date&lt;br /&gt;
              break&lt;br /&gt;
            end&lt;br /&gt;
          end&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      next_due_date = AssignmentDueDate.find_by(['parent_id = ? &amp;amp;&amp;amp; due_at &amp;gt;= ?', assignment_id, Time.zone.now])&lt;br /&gt;
    end&lt;br /&gt;
    next_due_date&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So this is issue is resolved by the state of the system itself.&lt;br /&gt;
'''''BUT Surprisingly on beta branch Reviewers aren't getting any emails at all'''''&lt;br /&gt;
&lt;br /&gt;
==Brief Introduction==&lt;br /&gt;
&lt;br /&gt;
* E2142. Improve e-mail notifications&lt;br /&gt;
* The forked repository can be found at: https://github.com/griffinbrookshire/expertiza&lt;/div&gt;</summary>
		<author><name>Ajulka</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2142._Improve_e-mail_notifications&amp;diff=139201</id>
		<title>CSC/ECE 517 Fall 2021 - E2142. Improve e-mail notifications</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2142._Improve_e-mail_notifications&amp;diff=139201"/>
		<updated>2021-10-19T20:29:43Z</updated>

		<summary type="html">&lt;p&gt;Ajulka: /* Issue - Don't send email to reviewers for a new submission after the review deadline has passed */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E2142. Improve e-mail notifications=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Work in progress==&lt;br /&gt;
This project is ongoing, and this page will be updated live.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Issue - Don't send email to reviewers for a new submission after the review deadline has passed ==&lt;br /&gt;
&lt;br /&gt;
'''Pre conditions'''&lt;br /&gt;
- There is an assignment, a student as a participant, a participant as a reviewer who is reviewing the this particular assignment&lt;br /&gt;
- a review is made for a submission by the student&lt;br /&gt;
- review deadline has passed&lt;br /&gt;
- the student is allowed to submit after the review deadline has passed&lt;br /&gt;
&lt;br /&gt;
'''Expected Behavior'''&lt;br /&gt;
&lt;br /&gt;
Exact issue stating the expected behavior can be found at https://github.com/expertiza/expertiza/issues/345 - &lt;br /&gt;
&amp;quot;Evidently, if a submission is revised after review, the system e-mails the reviewer saying to revise the review. This is just fine ... except if the last round of review has been completed.&lt;br /&gt;
The message telling reviewers to revise their reviews should not be sent after the last review deadline has passed.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
So basically, When the student makes a new submission after the LAST review deadline has passed. The reviewer should not receive an email, asking the reviewer to update the review according to the new submission.&lt;br /&gt;
&lt;br /&gt;
'''Actual Behavior'''&lt;br /&gt;
&lt;br /&gt;
According to the current Code scenario on the beta branch '''''if the deadline has passed, a student(participant) cannot make new submissions'''''. So, automatically if the participant doe not make a new submission then the reviewer wont receive an email. So this issue does not really exist by the virtue of the state of the system.&lt;br /&gt;
&lt;br /&gt;
==Brief Introduction==&lt;br /&gt;
&lt;br /&gt;
* E2142. Improve e-mail notifications&lt;br /&gt;
* The forked repository can be found at: https://github.com/griffinbrookshire/expertiza&lt;/div&gt;</summary>
		<author><name>Ajulka</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2142._Improve_e-mail_notifications&amp;diff=139198</id>
		<title>CSC/ECE 517 Fall 2021 - E2142. Improve e-mail notifications</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2142._Improve_e-mail_notifications&amp;diff=139198"/>
		<updated>2021-10-19T19:03:39Z</updated>

		<summary type="html">&lt;p&gt;Ajulka: /* Work in progress */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E2142. Improve e-mail notifications=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Work in progress==&lt;br /&gt;
This project is ongoing, and this page will be updated live.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Issue - Don't send email to reviewers for a new submission after the review deadline has passed ==&lt;br /&gt;
&lt;br /&gt;
==Brief Introduction==&lt;br /&gt;
&lt;br /&gt;
* E2142. Improve e-mail notifications&lt;br /&gt;
* The forked repository can be found at: https://github.com/griffinbrookshire/expertiza&lt;/div&gt;</summary>
		<author><name>Ajulka</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=User:Ajulka&amp;diff=138976</id>
		<title>User:Ajulka</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=User:Ajulka&amp;diff=138976"/>
		<updated>2021-10-11T16:08:50Z</updated>

		<summary type="html">&lt;p&gt;Ajulka: Blanked the page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Ajulka</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=User:Ajulka&amp;diff=138974</id>
		<title>User:Ajulka</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=User:Ajulka&amp;diff=138974"/>
		<updated>2021-10-11T16:07:21Z</updated>

		<summary type="html">&lt;p&gt;Ajulka: Created page with &amp;quot;E2142. Improve e-mail notifications&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;E2142. Improve e-mail notifications&lt;/div&gt;</summary>
		<author><name>Ajulka</name></author>
	</entry>
</feed>