yes_in
yes_in

Reputation: 11

translate regions and cities in osclass

Is it possible to translate cities as normal text without duplicating any table on the DB and only add the cities and their translations to .po here is a loop to list all the cities

<select name="sCity" class="selectar"  id="Scity">
<option value=""><?php _e('Select a city...')?></option>
<?php foreach($aCities as $city) { ?>
<option value="<?php echo $city['s_name'] ; ?>"><?php echo $city['s_name'] ; ?></option>
<?php } ?>

I tried this but didn't work

sprintf(__('%s'),  $city['s_name']);

Upvotes: 0

Views: 727

Answers (1)

Hussard
Hussard

Reputation: 676

This is not possible to translate those since there's currently no tables for it in the Osclass database.

To make it possible, you'll need to add at least two tables: oc_t_city_description, oc_t_region_description

The structure of those new tables will be similar to oc_t_pages_description.

Something like fk_i_pages_id, fk_c_locale_code, s_title.

You might wan't to ask Osclass team on the github of the project, by submitting an issue.

-

About your test :

sprintf(__('%s'),  $city['s_name']);

Gettext does not execute PHP to make the translation, you're just asking him to translate '%s' and not 'Paris', 'London' or 'San Francisco'.

Upvotes: 1

Related Questions