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

Amigo 2019-10-01 12:25:07 +02:00
parent 8ae8d017d5
commit d9b5b7ccff
1 changed files with 5 additions and 2 deletions

@ -5,13 +5,16 @@
[00:00:00](https://www.youtube.com/watch?v=_mXlbAO79J8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h00m00s)
(Click on these time links to see Youtube video)
This is a quick tip on how to add a language string to your component. Without a language string being immediately added to the Jtext object function, which translates it of course. Let me demonstrate. Normal language string, you would use Jtext and you'd [00:00:32](https://www.youtube.com/watch?v=_mXlbAO79J8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h00m32s) add your string in there. When JCB compiles it, it adds that string to your language file. When your component runs, that string is translated because it has a placeholder in its place. You can then have multiple places where the string is used. That's already there and works well. The new feature [00:00:59](https://www.youtube.com/watch?v=_mXlbAO79J8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h00m59s) is mostly used when you are dealing with a class and you are working with an array in the class. If you want to have class method or rather fields that is an array of strings, but you can't use this [00:01:20](https://www.youtube.com/watch?v=_mXlbAO79J8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h01m20s) in the array of a class value. That is one place but there are many places where you could see this in action.
How to add a language string to your component without a language string being immediately added to the Jtext object function which translates it. Let me demonstrate. With a normal language string, you would use Jtext and add your string in there(See Video). When JCB compiles it, it adds that string to your language file. When your component runs, that string is translated because it has a placeholder in its place. You can then have multiple places where the string is used. It is there and works well. The new feature [00:00:59](https://www.youtube.com/watch?v=_mXlbAO79J8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h00m59s) is mostly used when you are dealing with a class and you are working with an array in the class. If you want to have class method or rather fields that is an array of strings, but you can not use this [00:01:20](https://www.youtube.com/watch?v=_mXlbAO79J8&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h01m20s) in the array of a class value. That is one place but there are many places where you could see this in action.
### Want The Placeholder To Be Generated
[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 later in the script, you are 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 have 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.
### Looking At The Code