Hello, everyone, and welcome back in this lesson, we're going to talk about another internationalization
youth case, which is very similar to the plural youth case, where we have different alternative expressions
that are going to be applied depending on the value of a numeric amount.
Sometimes we have the same situation, but it's not necessarily in the context of a numeric amount.
Let's give an example.
If we switch over here to the Coast Guard component and we expect its template, we are going to notice
that we have here different translatable expressions depending on the value of the course category properties.
So we have heard the strings beginner, intermediate and advanced.
Now, one way of getting this translated would be to add the eatin' end to each of these DVS so that
each of the strings shows up in the extraction.
But instead of doing this, we would like to do this in a way that would give the translator some more
context about what is going on.
Instead of seeing these free expressions as completely unrelated in the translator user interface,
we would like these expressions to show up as being tightly linked and alternatives to one another.
This is going to give the translator a lot more context about these terms to give that context to the
translator.
We are going to replace here the use of energy switch by an expression very similar to the plural expression
that we wrote here.
Let's then refactor our code in order to use these new ETN mechanism.
We are going to move here to the use of the energy switch case clause.
We're going to leave here the deal with class category and say that we are going to add a new internationalization
expression.
Let's add a couple of curly braces to the limit, the expression and let's apply here the N attribute.
Now let's hear what is going to trigger our alternative choice in this case.
We know that is going to be the category property of the course member variable.
We are going to add here a comma and we are going to adhere here.
The select keyword.
These will indicate that this is a selection of alternative expressions.
Next, we are going to start adding here the multiple cases that we have available for our expression.
So first, we are going to say that whenever the course category variable contains the value beginner,
in that case we are going to be bringing to the screen the following string after the Virginia case.
We are going to be specifying here in a similar way the intermediate case for which we are going to
output the value intermediate.
And finally, we are going to apply here the advanced case for which we are going to write the string
advanced.
So here we have our expression completed.
In order to see this expression in action, we are going to need a list containing courses with all
the categories.
So we are going to switch here to our application component and we are going to remove here the use
of the filter by category pipe.
Next, we are going to head over to our terminal and we are going to restart here Yanguas Clay, once
we have our server up and running.
If we try things out, we are going to see that we get an error and the blank screen.
So it looks like our expression here was missing something.
And what we are missing is a comma here after the select.
So let's add that.
Let's reload the application and let's confirm that everything is working correctly.
So if we have a look here at our course list, we are going to see that there is something strange here
with the first course.
But the other courses we can see that we have here the label correctly displayed.
So we can see this expression here is an alternative in some cases to engy switch with the advantage
that it's compatible with the ETN extractor.
Now, let's have a look at what could have happened here in this first course where we are getting here,
this error.
And if we expect the data, we are going to see that indeed we have here a situation where the category
property of the course is missing.
Let's then adhere to the category property.
Let's set the category to intermediate.
Now, if we were to lower the application, we are going to see that everything is working correctly
as expected.
So our alternative select expression is working.
Let's now switch over here to the terminal.
We are going to stop the angular clay and we are going to run our Aetate in an extractor.
Now that the extraction is finished, let's have a look here at our messages file.
If we open it, we are going to see that now.
We have here another translation unit that is available here.
So as you can see, our expression is here available with all the alternatives.
So, again, this is going to be displayed in a user friendly way to the translator.
And the translator will know that clearly these are alternative expressions.
Let.
Now simulate the translation process, we are going to simulate that we send this file to a translator.
We're going to get a translated file and we are going to run the application in an alternative language.