Create a lang label based on database text

I’d like to create a {lang_something} based on text database. This means that “something” is text found on a database field and the label must be constructed programmatically as follows: {lang_{field}} There’s any way to do this or is not possible?

Not by default in scriptcase.

Thanks aducom, there’s any other way to to that?

I don’t think so. It’s an old - very - old wish on my wishlist as I would like to be able to let others do the translation(s) for me, and then I don’t need to give users access to the dev environment. Of course you can write your own libaries etc. and do the translation yourself, but for me that’s a no-go.

I supposed that, what a shame.

[SOLVED] It’s possible to do that! I found one way, by using the scriptcase internal object. See the next “trick”:
Imagine you have a lang key called {lang_test}. You can access this key programmatically on any event with the next call:


$this->Ini->Nm_lang['lang_' . $key]

Of course, you can check it before use:


if($this->Ini->Nm_lang['lang_' . $key])) {
echo "Exists";
}
else {
echo "Undefined key lang_{$key}";
}

Hope this will help you and will be very useful!

Dani

You can change the text yourself, but it is a bit messy.

This is what I do:

Make a new PHP method: lang_change

It has code like this:

$this->Ini-> Nm_lang ['lang_acc_fld_descriptn'] = "French descriptn";
 $this->Ini->Nm_lang['lang_acc_fld_acode'] = "German acode";

For a form/grid, call from onApplicationInit

lang_change();

This works. But it would be preferable for Scriptcase to provide us with an editable table-based solution:rolleyes:

Old topic, but very interesting one.
This is how I solve this situation:

  • In database, I create different fields for each language. In example, table “forms”:
    +++++++++++++++++++++++++
  • id + form_es + form_en +
    +++++++++++++++++++++++++
  • 1 + Señor + Mister +
    +++++++++++++++++++++++++
  • 2 + Señora + Miss +
    +++++++++++++++++++++++++
  • I put this code in “onApplicationInit” event: [language] = sc_get_language();
  • In field lookup, or in any place I need to call the table and get the term in proper language, I use: SELECT form_[language] FROM forms;

So easy!