WordPress.org

Forums

[resolved] How use custom locale (.mo/.po file) for custom posts? Is it proper thought? (7 posts)

  1. Lrrr
    Member
    Posted 1 year ago #

    Hello there, I wrote an EN article on my blog. Its a first EN article in my blog history so Im facing an issue. Sometime I will write further.

    How I can specify that WP engine should use different locale for translated strings only for specific posts?
    No matter if its on sigle page or archive?

    I read some sources like http://wordpress.stackexchange.com/questions/49451/change-locale-at-runtime but its not working unfortanetly for me nor this way will carry an permormance issue when used in archive i read somewhere...

    My progress to goal should be:
    1)Specify a taxonomy (tags category or custom) to sign the specific post
    2)detect it and assign the speciffic class (adding class not the question) to that post and consequently generate this post with other laguage strings in post footer etc.
    What I need is: Only one post in database only in one language as I wrote it! So I do not need translating text of the post. Just naturally wrote in english or in czech.

    Thank you for opinions. As a resuld should be this my post http://www.danielkral.cz/wordpress-dbc-backup-2-import-sql-problem-solved/ readable with proper english post footer, comments,connect etc. But only this one. Nest post shpould appear with czech footer, comments etc...

  2. middlesister
    Member
    Posted 1 year ago #

    This cannot be done from a theme but is possible from a plugin. This is because the locale is loaded before the theme file is included.

    Take a look at http://wordpress-hackers.1065353.n5.nabble.com/Multilanguage-how-to-redefine-locale-on-the-fly-td40876.html
    and http://wordpress.stackexchange.com/questions/89972/locale-switching-with-a-language-taxonomy

    The original poster decided in the end not to use taxonomies but to add a language indicator to the end of the post slug. Because the loading of the locale happens so early in the process, any conditionals such asis_term() hasn't been setup yet so you can't use them.

  3. Lrrr
    Member
    Posted 1 year ago #

    Thanks for respond.
    I will see the sources you gave me. (edit: first I know , second seems giving a clue! )
    Meanwhile, Im solving another issue with replacing strings given to the final html via shortcode which is part of a plugin.
    So you tell that I can not do upper thing from a theme (if i understand from a function.php in my child theme). So subsequently brings me a question. Is gennerally posible to filter a function which is inside the plugin from function.php in child theme?
    Because just now Im parsing shortcode and replacing. It could be much more elegant to do it via filter as filtering main theme.

    In general, basicly, I always assumed that via functions.php i can do anything in the wordpress... ?

    Thanks again for sources !

  4. middlesister
    Member
    Posted 1 year ago #

    Well you can do almost anything in a theme's functions.php. Take a look at
    http://codex.wordpress.org/Plugin_API/Action_Reference and then you can see that there are some actions that fire before the theme files are included. Thus, you cannot manipulate those from a theme file.

  5. middlesister
    Member
    Posted 1 year ago #

    Sorry, i forgot to answer your question about filtering a plugin. Yes it certainly is possible, but depends on how the plugin is written. The plugin needs to provide you with a filter in the first place.

  6. Lrrr
    Member
    Posted 1 year ago #

    Ok, thanks. I will take the time tomorow (myabe today its 0:40 am for me now) good night :)

  7. Lrrr
    Member
    Posted 9 months ago #

    I suspended this issue. Working with google translate. This way I decided as unapropriate. Thank you for answers I mark this thread as resolved :)

Topic Closed

This topic has been closed to new replies.

About this Topic