02Geek HTML5 and JavaScript, TypeScript, React, Flash, ActionScript online School
Previous VideoNext Video

Dealing with bi-directional paragraphs

Up until now copy that was added into our HTML object was treated as it is but in reality we really want to give it a style and make it our own. The following chapter describes ways we can manipulate text in CSS. We start our exploration with bi-directional text. By the end of this lesson you will know how to spot a copy that isn't well rendered even if it%u2019s not in your native language and will know how to fix it.

Video Transcript

00:00So far, we more or less ignored fonts and copy and the way copy is rendered, but no more.
00:07And we're going to start off this chapter as it's all dedicated to copy and text.
00:11We're going to start off by taking a deeper look into bilingual and really bidirectional languages,
00:18such as Hebrew and Arabic, which enable you to combine both Arabic and Hebrew in it.
00:23So most Arabic and Hebrew, well, not most, but Arabic and Hebrew,
00:27both combine a lot of times English into them, creating a plethora of issues.
00:32Now, this might not be important to you, so you could basically skip it
00:35if you'll never work with multilingual website application building.
00:39But if there's a chance you would, it is so important you watch this.
00:44Even if you'll never actually do it, you'll remember about it.
00:47So in the future, if you ever need to do it, you could refer back to it.
00:50So let's jump right into it.
00:51It's going to be the only lecture about language,
00:54and right after that, we're going to start working into the worldwide text-related things.
00:59So let's jump right into it.
01:00To be able to start this sample, we're going to need a bidirectional copy inside our paragraph.
01:06To do that, I'm just going to go to Google Translate,
01:09and what I'm just going to do is just have on one side English or whatever your native language is,
01:14and on the other side a language that is not left to right but right to left,
01:20such as Hebrew or Arabic.
01:23So I'm going to go ahead here and just write here cats don't like dogs.
01:29Now, you could write whatever sentence.
01:31Really, the point is just to create a sentence.
01:33I'm going to go ahead here and just copy it by copying it.
01:36And I'll go right into my editor and just go into a paragraph
01:41and a little bit before the break of the line, I'm just going to, where the line breaks,
01:46I'm going to add some copy and put a space there and save.
01:49Now, I want you to notice something.
01:51Notice how the copy here is written upside down.
01:54Well, in our browser, when we're looking at it, this copy is not written in the same way.
02:00So if we just take a look at the two together, one next to each other,
02:04notice how, if I'll just set it, notice how it's actually written exactly the opposite
02:10because we're really in an editor that is an English-speaking editor.
02:14And by adding copy that is not in English, it doesn't really know what to do with it.
02:18So it's just adding it into the paragraph in the most natural way that it knows how to.
02:23But that doesn't mean that that is how the browser would render it.
02:27If we go now into the browser, just opening it up again,
02:30notice how it's going to actually by default render.
02:33So notice how we have your cats, well, basically it's reading your cats don't like dogs
02:38and it's broken down into two lines.
02:40But are these two lines reading the copy phonetically correctly?
02:44And they are.
02:45So we could see that here they're upside down, but here they're not upside down.
02:50All the rules that govern how to do these stuff are happening automatically,
02:55which for the most part in a modern web experience,
02:58you really don't have to worry too much about the alignment.
03:01The only question here is, is our copy really,
03:04do we really want our copy to be aligned from left to right in general?
03:09Or do we want our copy to be aligned from right to left, from right to left or left to right?
03:14In this case, the sentence begins here and it continues on,
03:18then continues from this direction here and then from here to the end here
03:24and then going back all the way to this direction,
03:26which is intuitive and natural if you speak both languages
03:29and reading a paragraph that is mainly in English.
03:32But if the paragraph was mainly in Hebrew and there was some English in it,
03:36we would expect the paragraph to actually start really the other way around.
03:41Now, in those scenarios, you would go into your editor
03:44and I'm just going to go into this paragraph and just add it into, add to it a class.
03:49I'm just going to call this class multi, for multi language.
03:55And for this multi language class, I'm just going to go ahead here and save here,
03:59save it, go to my paragraph and right underneath my article paragraph,
04:03I'm just going to add another article P, multi.
04:09And in this scenario, what do I want to do?
04:11I want to go ahead to my direction and I literally want to say,
04:14hey, by the way, your direction is not going to be right to left or sorry,
04:18left to right, which was your default.
04:20And we want to turn it to be right to left.
04:23Now, by creating this change and setting it to be right to left,
04:27which is not the default.
04:28The default is just English because and languages that go from left to right in general.
04:34And if I go ahead here and click on refresh,
04:35you'll see that the copy formatting itself is going to be adopted.
04:39And then let me just make sure that I save it.
04:41The copy itself is going to be adopted and I'm not really seeing here.
04:45So let me make sure that I could see that it's actually being implemented
04:49and it's definitely not being implemented.
04:51I don't see the multi configured.
04:54So let me just go ahead here and just make sure that I've created
04:57this multi law appropriately.
05:00And I have absolutely did not because what I wrote here is article.
05:03Okay, so we're inside of an article.
05:05Then I wrote a paragraph and inside of that paragraph multi,
05:08what I really wanted to do is just connect them together that a multi paragraph
05:12or just remove the paragraph.
05:13So we'll go ahead there and save that and click on refresh.
05:16And hopefully this time around, we'll see that our copy is now switched around.
05:20And now the layout itself assumes that we're a Hebrew reader.
05:23So in this case, we would read the in English,
05:26move to Hebrew and so on and so forth.
05:28And that is the decision that you want to make between if you're in a language,
05:32for example, that is Arabic or Hebrew,
05:34you would want your copy to start from the other direction.
05:37In general, even though the copy by default would be presented in a readable way.
05:42Now, before we complete this topic, I want to go ahead here and just add here
05:47into the comment section just so you could have access to the different options,
05:51which we already explored, which was the default, which was left to right.
05:55We can turn it to right to left.
05:58And if we define as right to left, for example,
06:00in the top of our application in our body,
06:02then everything would be right to left because it's automatically inherited
06:06unless we decide to convert something specifically to a different format.
06:11Now, sometimes you will get copy that will not transcribe correctly.
06:16What we would do in those type of cases is really a very, very simple question.
06:21Now, by the way, one of the stuff that we want to, by default,
06:26the ordering of our words and the decision of what comes before what
06:31structure it will have is really just based on the normal ordering of our application.
06:37Now, if we want, which is basically implicit,
06:40it runs behind the scenes and makes the decisions based on that.
06:43Now, if we want that direction to change,
06:46but to change based on the actual direction we define in the paragraph,
06:49we would then set the beyond setting a direction.
06:53We would also go to something that's called Unicode BD for bi-directional copy
06:58and say, what rule do you want to apply to this bi-directional rule?
07:02If we're not happy with the normal, which is the default,
07:05we could go for the embed option.
07:07Now, the embed option is, you know,
07:09and it's a little bit hard to see the difference between the embed option
07:13and the normal option, but really the big difference between them is not very big.
07:19You really want to just test out and see which one works more appropriately for you
07:22and it's really specific and it's really, in this case,
07:26we don't really see a difference between the one and the other
07:28because the default rendering and also the embed
07:33worked more or less the same exact way in this scenario.
07:37Places where you're going to see these type of issues more explicit usually
07:41is where you see periods.
07:43So, if I go ahead and I change my direction now from RTL to back to left to right,
07:49I want you to notice that my paragraph,
07:51even though it initially has your a dot in the end,
07:55sometimes, and for example, here we have a comma on this side instead of this side
07:59because we're in the Hebrew format.
08:01But if we go ahead and click on refresh,
08:03notice that our dot is in the right spot,
08:06but our dot for our end of the sentence is not in the right spot
08:12because it should have been in the end of the sentence,
08:14which is this word, klavim.
08:17Now, this word should have the dot right after it,
08:20but it's not because we are in the LTR in our embed.
08:26We're using an embed and maybe not the normal.
08:29So, if we set the normal, then we could test it out
08:31and really this is the matter of playing with it
08:33and finding it, especially if you speak those languages,
08:35to find the match that would work for you best.
08:38And it wouldn't be always 100% perfect,
08:40like in this scenario where the dot is not very explicitly Hebrew
08:44or explicitly English, and those are really the places
08:47where you have those type of issues most commonly.
08:49And unfortunately, you would have to come up with a solution,
08:52such as removing the dot or putting the dot,
08:54trying to put the dot in a different location.
08:57So, if we look into this paragraph and we have this dot right here,
09:00we might want to test it out by setting it in a different spot,
09:03but really, in general, this is a very common issue.
09:06You might want to just instead of that put there a dash
09:08and just separate it with a dash.
09:10So, there's like a clear separation between the two that is not a dot,
09:13and it's really just into your consideration to figure out
09:15what would be the format that would work for you best.
09:18Now, another way for you to solve this problem
09:21is going into your biodeirectional pamphlet area there,
09:27and instead of saying for it to work in its natural formatting
09:30or instead of telling it to embed,
09:34we could give it one more option,
09:36and that option would be to have a B, D override.
09:40Now, what that means is it's a complete override
09:43that just follows as if it was all English
09:46or left to right or right to left.
09:49And in that case, we really would get that language
09:51that is completely upside down,
09:53but it gives us a lot more control
09:55into deciding where would we put that dot,
09:57because we could manually just switch it around
09:59to the direction that we want it to be.
10:01For example, in a case like this, that might work for me
10:04because I want it to be something very small.
10:06So, then I could go ahead there and just copy it
10:08the way I want it to be, put it in letter by letter,
10:11knowing that there won't be any switch.
10:13I'll have complete control over every single character
10:16and where it would appear,
10:18but that is very problematic,
10:19especially in a design that is resizable.
10:21If our design was not resizable,
10:23then that would probably work perfectly
10:25if we wanted to force it in a manual way.
10:28Now, you don't have to worry too much about this,
10:30nor do you have to memorize it,
10:32but it's good to know about it.
10:34Now that you know about it,
10:35if you ever encounter a situation
10:37where you have a need to work with a foreign language
10:40that you don't speak or even the language
10:42that you do speak,
10:43you'll know what are the points you would want to look for
10:46to make sure that your content will be rendered
10:48at the most appropriate way.
10:50Really, the question here is always a question
10:52of how much copy.
10:54If it's a really small amount of copy,
10:56maybe a BD override would be more fitting
10:59than the natural setting.
11:01If you have quite a lot of copy,
11:03you'd probably would want to lean on the default
11:05or the embed in test to see
11:07which one gives you the best result that you can have.
11:10So that's it about the language itself,
11:12and here on, don't worry, we're back to English
11:14and we're back to looking deeply into the different ways
11:17that we could control text
11:18and present it in different ways on our screen.
11:21So we're going to see that in the next lecture.

Ready to Level Up Your Skills?

Join thousands of learners on 02GEEK and start your journey to becoming a coding expert today!

Enroll Now for Free!