not possible to translate strings using posttype name

This topic contains 4 replies, has 4 voices, and was last updated by  Stiofan O’Connor 8 years, 3 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket

Tagged: ,

  • Author
    Posts
  • #260844

    Rainer Lang
    Expired Member
    Post count: 33

    Hello,
    in the add listing screen “Place Title” and “Place Description” cannot be translated via language files.
    We looked into the code, the used sequence is “%s Title” and “%s Description”, which can be translated, but is a messy thing for some languages, because e.g. in German we would translate the whole string differently and “Place” has different grammatical forms in German.
    The string “Place” cannot be translated at all, because it just uses the name of the posttype, e.g. in geodirectory_template_actions.php around lines 2180 rsp. 2215 and 2267.
    Please change that to real i18n strings like __(‘Place Title’,’geodirectory’).

    As the two main posttypes are places and events, I’d suggest to add after line 2215 for example to:

    
    
    <label><?php 
    if($cpt_singular_name == 'gd_place')
    _e('Place Title', 'geodirectory');
    elseif($cpt_singular_name == 'gd_event')
    _e('Event Title', 'geodirectory');
    else
    echo sprintf( __('%s Title', 'geodirectory'), $cpt_singular_name ); 
    ?><span>*</span> </label>
    #260889

    Guust
    Moderator
    Post count: 29970

    You normally change “Place” using custom post types addon to whatever you want it to be, not with the language file. And then you can translate “%s Title” and “%s Description”.

    #261619

    Rainer Lang
    Expired Member
    Post count: 33

    Using custom post types addon maybe a solution just for renaming, but why use another addon if we just need translation in our language?
    The language strings “%s Title” and “%s Description” are really bad i18n practices. For your better understanding:

    We use the two post types places and events.
    Translation in German:
    “Place” = “Platz”, with article: “Der Platz”
    “Event” = “Veranstaltung”, with article: “Die Veranstaltung”

    The correct translation would be:
    “Place Title” = “Titel des Platzes
    “Event Title” = “Titel der Veranstaltung”

    You see?

    #262069

    Paolo
    Site Admin
    Post count: 31206

    Hi,

    I’ve flagged this for the developers, they will let you know asap.

    Thanks

    #262531

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    This is the correct way to do things, the post type can be anything, it is dynamic.

    From the developer guide: https://codex.wordpress.org/I18n_for_WordPress_Developers

    printf( esc_html__( 'Your city is %1$s, and your zip code is %2$s.', 'my-text-domain' ), $city, $zipcode );

    From WordPress itself: https://github.com/WordPress/WordPress/blob/01c3ae084bbc52f9e732b5b5e1069e0e4e3061e3/wp-admin/includes/class-wp-terms-list-table.php#L338

    sprintf( __( 'Select %s' ), $tag->name )

    If you want to translate individual post type names into diferent languages you can use this technique https://wpgeodirectory.com/docs/translating-custom-fields/

    Thanks,

    Stiofan

Viewing 5 posts - 1 through 5 (of 5 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
20% Discount Offer
Hurry! Get your 20% discount before it expires. Get 20% Discount