in reply to Multilingual design

G'day Bod,

I had to do this for $work about 20 years ago; I expect my memory is somewhat shaky on details by now. Here's what I remember as it applies to your general design. I believe there are now a number of applications which will do much of the heavy lifting; it may be better to use those instead of re-inventing wheels yourself. I'll be interested in what others suggest.

Firstly, just use one set of templates. Improve readability with meaningful id="...", class="...", etc. names; remember you can use multiple class names.

This seems to align with what you suggested as your first option. I don't see any MVC-violation; please explain more about what you meant.

Store translations in separate directories. If you're going to include language variations, store the main language (let's say fr for French) in one place, and then variations (e.g. fr_ca for Canadian-French) separately. The variations would be smaller and only need to overwrite parts of the main language. To use a Perl-based pseudocode (which isn't necessarily suggesting implemention):

%lang = (%lang_fr); # French %lang = (%lang_fr, %lang_fr_ca); # Canadian-French

Organise translations into useful categories. For instance, button text ("Submit", "Cancel", etc.) would be widely used and perhaps suitable for a "common" category; text specifically for the "Left-handed Sky Hooks" pages could probably go into their own category.

Bear in mind that scripts can be left-to-right (e.g. Cyrillic & Greek) while others are right-to-left (e.g. Arabic & Hebrew). Your overall layout design would need to take this into account. In some cases you could just the change direction of the text:

+-------------+  +-------------+
| LTR Lang    |  |    gnaL LTR |
| Description |  | noitpircseD |
+-------------+  +-------------+

Others may be a bit more complicated if controls need to be moved as well:

+---------+-----------+
| Prompt: | [_______] |
+---------+-----------+

+-----------+---------+
| [_______] | :tpmorP |
+-----------+---------+

There are other considerations related to scripts (e.g. fonts & encoding). I'd suggest having a "meta" (or similar) category for each language to hold this information.

Navigation of a multi-lingual site needs to be addressed. Here's a couple of examples of the types of issues that could be encountered:

As you can see, there's more involved than simply translating text.

Edit: A few cosmetic changes; no information added, deleted, or substantially changed.

— Ken

Replies are listed 'Best First'.
Re^2: Multilingual design
by marinersk (Priest) on Dec 11, 2022 at 03:38 UTC

    When we did our first serious multi-lingual deployment, we also had to contend with languages which read top to bottom first, and then either right-to-left or left-to-right.

    Just another (pardon the pun) dimension of complication.

      "... we also had to contend with languages which read top to bottom first ..."

      I never had to deal with that, I'm pleased to say.

      Thank God no one uses boustrophedon any more.

      — Ken

Re^2: Multilingual design
by Bod (Parson) on Dec 11, 2022 at 22:55 UTC

    Cheers Ken for the great reply...as always you get the thought process moving in the right direction!

    I don't see any MVC-violation; please explain more about what you meant

    In the first solution I came up with, I was suggesting passing the language specific text from the script to the template.

    my $vars; if ($lang eq 'en') { $vars = { 'heading' => 'Dies ist eine Einführung', 'text' => 'Hier ist ein Beispiel für einige Inhalte', 'seemore' => 'mehr sehen...', }; } elsif ($lang eq 'au') { $vars = { 'heading' => 'G\'Day, this is an intro', 'text' => 'Hey Sport, just a little example', 'seemore' => 'want more...', }; } else { # Default to English $vars = { 'heading' => 'This is an introduction', 'text' => 'Here is an example of some content', 'seemore' => 'see more...', }; } $template->process('intro.tt', $vars);
    I wouldn't implement it like that, but it shows my thought process...

    I quickly moved on from there and went for having the template variables in their own template file and using a PROCESS directive to set the correct language. I only included the first option so you could get a glimpse of how my mind dealt with the stages of developing the idea.

    I'll come back to the rest of your post in a while.