WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How to enable Gengo language chooser elements in sidebar? (5 posts)

  1. LostInNetwork
    Member
    Posted 6 years ago #

    Does anybody know how to add the Gengo "current languages" and "available languages" elements to the sidebar as is done at wp-multilingual.net?

    Looking at the page source code, I can see that some sort of script was used to produce those language selection tools.

    Thanks

    ps. I do have Gengo set up, but at present I can only change the language in the url, which is inconvenient.

  2. moshu
    Member
    Posted 6 years ago #

    Isn't that explained in the readme???
    Like:
    gengo_list_languages() - outputs a formatted lists of languages defined for this blog. Surround the call to this function with <ul> tags.

  3. LostInNetwork
    Member
    Posted 6 years ago #

    The readme didn't tell me that I should edit the gengo.php file on row 1324 to replace gengo_list_languages(...); with gengo_language_control();

    Did that. Now I can view the site in one language, two languages (any combination), or three languages.

    I might switch back to the basic model later, or maybe not.

    Next I need to figure out how to inject flags there.

  4. LostInNetwork
    Member
    Posted 6 years ago #

    Solved.

    The default widget was problematic, as I ended up with a start page that was in one language that I could not change, or then it was in three languages (fi+sv+en) - of course giving me all the subpages three times. I wanted it in ONE language and then I wanted to change it, if need be. I tried several combinations of the Gengo settings (allow/disallow multiple languages; show in one/all languages; let Gengo decide). Nothing seemed to work and I felt lost without extensive documentation. Nothing new...

    Then I found the language_control function and edited the gengo.php. That helped a little. I could add/remove languages and save, and after that I had those languages visible that I wanted. But it was inconvenient.

    The solution was simpler than I could imagine:

    I created a text widget with hyperlinks to http://blog.net/XX, http://blog.net/XY, http://blog.net/XZ (where XX,XY,XZ are language codes) using IMG tags to insert polyglot flags.

    Now I have Gengo set to display all pages in one default language, finnish, first. Then I can use these links to switch languages.

    I also needed to edit my theme to add /"<?php the_language_code(); ?>" at the end of the blogname (that works as a link to the posts page) in the header.

    This works like a charm.

    I'll need to work on some widgets still, to have their headers translated. And the contents of some widgets will pose a challenge...

    Anyway, I can achieve what I want with Gengo.

  5. LostInNetwork
    Member
    Posted 6 years ago #

    Also, translations in the sidebar of

    (POST) CATEGORIES HEADERS

    in widgets.php function wp_widget_categories after $title = ... add:
    $title = gengo_snippet($title,true);

    LINK CATEGORIES HEADERS

    in bookmark-template.php function wp_list_bookmarks after $catname = ... add:
    $catname = gengo_snippet($catname,true);

    ARCHIVES HEADER

    in widgets.php function wp_widget_archives after $title = ... add:
    $title = gengo_snippet($title,true);

    Then go to WP dashboard > Language > Synonyms
    and start creating "snippets" for all these category/widget titles. The snippets name should be the widgets/categorys untranslated original title. If you have not defined all these snippets (in all languages), then some of the translated titles will obviously be empty. To avoid that little inconvenience, replace the code above with something a little bit more "complicated":

    $title_translated = gengo_snippet($title,true);
    empty($title_translated) || $title = $title_translated;

    There the substitution is not done, if the new value is empty.

    Now repeat this to all the titles you can find in all your widgets, and you'll have a nice multilingual blog :)

Topic Closed

This topic has been closed to new replies.

About this Topic