Multilingual apps

The recommended method of customizing your AppGini-generated application is through hooks. But sometimes you might need to add functionality not accessible through hooks. You can discuss this here.
Post Reply
SkayyHH
Veteran Member
Posts: 425
Joined: 2015-04-27 21:18

Multilingual apps

Post by SkayyHH » 2020-09-22 19:43

has someone already created a multilingual app with appgini? I have no idea how I can have the table names and field names and labels multilingual without creating the app twice with the Appgini ide. The language files are not for the field names. Maybe someone has phprunner and knows what I mean. There i can store several languages for each label.

Thanks much, Kai

balfons
Veteran Member
Posts: 91
Joined: 2018-10-22 15:27

Re: Multilingual apps

Post by balfons » 2020-09-23 09:38

Hi everybody!

Just found this post and I have the same problem. I need both the application and the table names in, at least, 2 languages.

Anyone having a solution/workaround?

Thanks in advance

hgarbe
Veteran Member
Posts: 57
Joined: 2020-01-21 17:35

Re: Multilingual apps

Post by hgarbe » 2020-09-24 07:00

I can remember this post here: viewtopic.php?t=3059
Should be going towards to what you try to achieve. But only covers the the language.php not your table fields description. Someone proposed a solution a time ago with using different table views but I didn't find that post ...

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1156
Joined: 2019-05-21 22:42
Location: Germany
Contact:

Re: Multilingual apps

Post by onoehring » 2020-09-26 14:07

Hi,

afaik, there is no simple solution to this at this time.
Maybe you can follow this quick and very dirty blueprint.Single sentence: Make use of the /hooks/tablename.php -> _init function to manipulate page output.
I try to do it more detailed but it's not thought through (just as a warning). A quick search in one of my AG applications shows that this might work - no strings attached.

Preperation I
Make sure, you have some system to name your fields (header of your fields which are shown in your browser). Let's say, my field for lastname is usually names Lastname. By system I mean make sure, you have a way to search field names (in php) and find them, all of them, but only them.

Example: Let's say, I decide to name all fields with a prefix preFLD_ and the postfix _postFLD. My fieldname for Lastname would then become preFLD_Lastname_postFLD.

Preperation II
As we are talking about translation, you will need some translation tables:

Table: BaseValues
ID_BaseValues: PK autoincrement
BaseValue: Varchar 200 (or as much as fieldnames can be in MySQL), unique. Example entries: preFLD_Lastname_postFLD, preFLD_Birthdate_postFLD

Table: Languages
ID_Languages: PK autoincrement
Languages: Varchar 200 (or as much as fieldnames can be in MySQL), unique. Example entries: English, Deutsch

and our join table:
Table: BaseValues_Languages
ID_BaseValues_Languages: PK autoincrement
ID_BaseValues: Lookup for BaseValue from table BaseValues. Shown in the field for example: preFLD_Lastname_postFLD or preFLD_Birthdate_postFLD
ID_Languages: Lookup for ID_Languages from table Languages. Holds target language for this translation of the ID_BaseValues (BaseValue) fieldname-string. Shown in the field for example: English or Deutsch
FieldTranslation: Varchar 200 (or as much as fieldnames can be in MySQL), unique. Example entries: Nachname, Geburtsdatum

Bonus: To keep up a nice database design, access this table (once created by your app) in phpmyadmin (or similar, AppGini can not do this directly :-( ) and set a contraint on the field combination of ID_BaseValues with ID_Languages: The combination of these should be unique (to limit the error margin that you do a translation for a single field more than once).

Of course, you will need to translate your field labels (in the table BaseValues_Languages) before doing adjustments!

Doing adjustments
Do I need to add: You will need some way to determine the language the users wants to use. Save this to a session variable, so you can use it in the following:
Once this has been done, add some code to the tablename.php -> tablename_init function.
This code simply searches your naming-system: One it has found a field label in the HTML code you should make use of your translation tables, grab the translation you want and replace preFLD_Lastname_postFLD with the actual fieldname according to the language of the user: Lastname for english or Nachname for german.
Once all occurences of your sytematically-strange-field-naming-system ;-) have been replaced with the target language, finish the HTML and return ist for rendering.

I strongly suggest creating the code for doing adjustments in a new file and function, so it can be reused.

Any suggestions?
Olaf

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: Multilingual apps

Post by pbottcher » 2020-09-26 15:13

Hi,

maybe this is somewhat the direction you are looking at

viewtopic.php?t=3573#p13067
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

balfons
Veteran Member
Posts: 91
Joined: 2018-10-22 15:27

Re: Multilingual apps

Post by balfons » 2020-10-06 15:47

Thanks for all your answers. I think I'll try first to look at those previos threads you recommend.

Post Reply