Skip to content

067 Adding Language String to your Component and get the Language Placeholder for dynamic use

Amigo edited this page May 15, 2019 · 7 revisions

This is a quick 00:00:03 Sort of tip on how to add a language string To your component Without a language string Being immediately Added to the J text Object function Which translates it of course So let me demonstrate So normal language string you use this J text And you'd 00:00:32 Add your string in there And then JCB when it compiles It Actually adds that string to your language file And then when your component runs that string is translated because it has a Placeholder in its place And you can then have multiple places where the string is used So that's Already there and works well the new feature 00:00:59 Is Mostly used when you are dealing with a class And you working with a Array In the class And If You want to have class method or rather Fields That is an array of Strings but you can't of course use this 00:01:20 In the array of a class Value so That is one place but there are many places Where you could see this in action So what you would wanna 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 00:01:52 to the Jtext Option to translate this place holder 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 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 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 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 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 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

Clone this wiki locally