hotzen
hotzen

Reputation: 2873

Language-Dependent DAO (i18n)

I created DAOs for my database tables. In SAP ABAP you can have additional text-tables which contain the language-dependent texts (language-code is part of the key). Currently I create DAO-instances right at the beginning of the program (Dependency Injection) and pass them a language-key which effectively binds the DAO to a specific language and let's the DAO read texts only from that specific lagnuage.

However later in the program I am required to get texts from another language. How do I cope with this?

Every advice greatly appreciated

Upvotes: 0

Views: 136

Answers (2)

vwegert
vwegert

Reputation: 18493

I would probably add a parameter to the getter and setter methods that deal with language-dependent texts and set its default value to SY-LANGU. This way, l_foo = lr_bar->get_baz_text( ) will implicitly get the text in the language the user logged on with, and l_foo = lr_bar->get_baz_text( l_target_language ) will retrieve the text in any other language. You might want to pre-fetch the text in the current language when creating the object and use a hashed table to store the language-dependent texts.

Upvotes: 1

tomdemuyt
tomdemuyt

Reputation: 4592

In SAP, the selected language is part of the session. Your program could also have a globally available 'session' singleton where you store the user language choice.

Upvotes: -1

Related Questions