• Resolved burria

    (@burria)


    Hi! I’m trying to figure the best way to prepare a plugin, that could be used by infinite number of languages, for letting the admin translate their own inputs in a bilingual website.

    The exact functionality is not really important, and I haven’t write it yet but basically the admin from the settings page will be able to add forms for a content type.

    For example “Name”. So he needs the power to translate this string to “Nombre” when the user is looking the web in Spanish.

    I don’t need a “User Friendly Solution”, but for example if someone wants to translate my plugins to Italian he just needs to install a plug-in and translate the strings, but this won’t be possible with user inputs.

    I was unable to find any info on Google and the Codex, so i’m lost at this point.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    As you may know, the coder’s solution revolves around gettext() and .pot, .po and .mo files. Translations are initiated through functions like __() and _e(), etc. You could implement a UI that works through the same mechanisms. This would normally involve some command line tools, but I believe there would be ways to achieve the same with PHP. When the user has completed entering their strings, you plugin would generate the proper .mo file.

    When it comes time to output the user’s string, your plugin would determine which translation function to use and pass the user’s string through it. The normal gettext() system will then take care of the rest.

    Alternately, you could implement your own system that involves table look ups to achieve the same end. For example, the first table column has the primary language strings that the user supplied. The next column is assigned to the alternate language and contains translations of the first column content.

    When it comes time to output a string, the current locale is determined, and if it’s the alternate language, the primary string is located in the table and the corresponding alternate string is output. Otherwise output the primary string directly.

    Thread Starter burria

    (@burria)

    Thank you @bcworkz, my original idea was to create a ‘tag system’ and then parse it, but I’ll experiment on your first solution.

    I wanted to be sure there was not an standard way to do it.

    Moderator bcworkz

    (@bcworkz)

    Happy to toss out random ideas! Working with the gettext() system would be as close to a “standard” way of doing it, but could be cumbersome to supplant the command line tools. If you can work that part out, that would be the way to go. There’s not really any standard approach, there are several multi-language plugins and there are several methods employed among them. I believe a “tag” system may be one off them.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Internationalizing user input’ is closed to new replies.