Updated 067 Adding Language String to your Component and get the Language Placeholder for dynamic use (markdown)

Amigo 2019-09-30 08:10:10 +02:00
parent bf9d680071
commit 34ee7f455e

@ -11,5 +11,10 @@ This is a quick tip on how to add a language string to your component. Without a
[00:01:32](https://www.youtube.com/watch?v=_mXlbAO79J8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h01m32s) [00:01:32](https://www.youtube.com/watch?v=_mXlbAO79J8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h01m32s)
??? What you would want to do is you want the placeholder to be generated. You want the string to be added to the language file. But you only want a placeholder as a string to be added to your Script. Because later in the script, you're going to add it to the Jtext option to translate this placeholder. Often you would run into such a case, well I have. The way we've addressed this with a new name JustTEXT. [00:02:16](https://www.youtube.com/watch?v=_mXlbAO79J8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h02m16s) This part looks exactly the same as the Jtext. This almost seems like this is a class but it's not really. It's something that the JCB compiler will pick up. It'll convert this, let me show you how it will look when it has converted. You'll see why it makes sense. You will see I've got this extra field properties, and it have these keys(listclass, escape, display and validate). I want to use the key to get the string. If we go a little lower in the script, [00:02:49](https://www.youtube.com/watch?v=_mXlbAO79J8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h02m49s) you will see I'm looping through that array and the value description. I'm only passing it to the Jtext to translate it. That means I want to do the this translating later and all I want in this array above is the placeholder string.
What you would want to do is you want the placeholder to be generated. You want the string to be added to the language file. But you only want a placeholder as a string to be added to your Script. Because only later in the script you're going to add it to the Jtext option to translate this placeholder. And so often you we would run into such a case well I have in anyway so The way we've addressed this Is with a new Basically a new name Just text Like that so [00:02:16](https://www.youtube.com/watch?v=_mXlbAO79J8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h02m16s) This part looks exactly the same as the J text So this almost seems like this is a class but it's not really it's just Something that the JCB compiler will pick up And it'll convert this let me show you how it will look when it has converted it And you'll see why it makes sense you see I've got this extra field Properties And it's got these Keys And I want to use the key to get the string So if we go a little lower in the script [00:02:49](https://www.youtube.com/watch?v=_mXlbAO79J8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h02m49s) You see I'm here I'm looping through that array And The value description I'm only here passing it to the J text To translate it So that means I wanna do the this translating later And I actually all I want in this array above here is actually the placeholder string So let me show you that in the code how it actually comes out [00:03:16](https://www.youtube.com/watch?v=_mXlbAO79J8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h03m16s) So in the code here you see the extra field properties and you see it's simply a a string It actually took away the bracket here if you look at the way it was So I'm going to paste in the The one from the code Just so that you can see What it's done So here you can see [00:03:40](https://www.youtube.com/watch?v=_mXlbAO79J8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h03m40s) This is what we added in JCB And this is what it did In compilation It added the placeholder string Which we can then use Down here In our Jtext To translate it to get the Specific translated string So that's a way to get the placeholder and to get obviously the string into your language file [00:04:09](https://www.youtube.com/watch?v=_mXlbAO79J8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h04m09s) That's just a little tip I know that It's not very obvious So I hope it will come in handy to those of you who want to add language strings To JCB But you don't want to have it immediately be Part of the Jtext object Call you want to just have the actual placeholder available for use dynamically This is the way you can do that Thanks for watching enjoy
### Looking At The Code
[00:03:11](https://www.youtube.com/watch?v=_mXlbAO79J8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h03m11s)
Let me show you that in the code how it comes out. In the code you will see the extra field properties. You will see it's simply a string. It took away the bracket, if you looked at it the way it was. I'm going to paste in the one from the code that you can see what it has done. You can see [00:03:40](https://www.youtube.com/watch?v=_mXlbAO79J8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h03m40s) this is what we added in JCB, and what it did in compilation. It added the placeholder string which we can then use down here in our Jtext to translate it to get the specific translated string. That's a way to get the placeholder and to get the string into your language file. [00:04:09](https://www.youtube.com/watch?v=_mXlbAO79J8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h04m09s) That's just a little tip. I know that it's not very obvious. I hope it will come in handy to those of you who want to add language strings to JCB, but you don't want to have it immediately be part of the Jtext object call. You want to have the actual placeholder available for use dynamically. This is the way you can do that.