*

7ala

  • ****
  • 144 posts
Hello all
The problem of the language of cities appears only in English
In the search, the language of the cities appears in English only
While in adding an advertisement, it appears according to the chosen language
this code
<option value="<?php echo $region['s_name'] ; ?>"><?php echo $region['s_name'] ; ?></option>
Thank you all

*

osclassic

  • ***
  • 34 posts
Re: The problem of the language of cities appears only in English
« Reply #1 on: July 30, 2021, 12:35:40 AM »
Only cities? Pretty much everything stays in English when a language is changed and the whole language thing in osclass is not programmed well and it does not make any sense even to implement different languages - it is better to leave everything in English. May be, because it is the way most templates are written but I am yet to see a osclass website that does the language and country change make it seamless to the user. I already made another post with an example to show how it is done by another script and how it should be from the end user standpoint.

*

MB Themes

Re: The problem of the language of cities appears only in English
« Reply #2 on: July 30, 2021, 07:58:37 AM »
@7ala
check this one:
https://docs.osclasspoint.com/translate-osclass-locations

It is required to change these into following form:
Code: [Select]
$country['s_name'] --->  osc_location_native_name_selector($country)
$region['s_name']  --->  osc_location_native_name_selector($region)
$city['s_name']    --->  osc_location_native_name_selector($city)
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

7ala

  • ****
  • 144 posts
Re: The problem of the language of cities appears only in English
« Reply #3 on: July 30, 2021, 01:12:13 PM »
Thank you very much
This solution worked

Code: [Select]
<option value="<?php echo $region['s_name'] ; ?>"><?php echo osc_location_native_name_selector($region) ; ?></option>
Thank you again
« Last Edit: July 30, 2021, 01:13:58 PM by 7ala »

*

7ala

  • ****
  • 144 posts
Re: The problem of the language of cities appears only in English
« Reply #4 on: July 31, 2021, 01:22:19 PM »
Welcome
Another problem appeared
Unfortunately, the problem with the city is not in the same language as the chosen one
Also, why is the selected search not saved?
this code
Code: [Select]
<?php ItemForm::region_select(osc_get_regions(osc_user_country())); ?>
<div class="label"><?php _e('City''eva'); ?></div>
                            <select id="sCity" name="sCity" >
                                <option value=""><?php _e('Select a City...''eva'); ?></option>
                            </select>

And thise

Code: [Select]
$('#regionId').change(function updateCityList() {
                    var actualRegionId   = $(this).val();

                    if ( Math.floor(actualRegionId) == actualRegionId && $.isNumeric(actualRegionId)) {
                        /*Get cities per region*/
                        $.ajax({
                            url: "<?php echo osc_base_url(true); ?>?page=ajax&action=cities",
                            data: { regionId: actualRegionId },
                            success: function( cities, err){
                                var $el = $("#sCity"),
                                    citiesOptions = {};

                                $('#sCity option:gt(0)').remove();
                                $el.val("");
                                $el.prev("span").text("Any City");
                                $.each(cities, function(key, value) {
                                  $el.append($("<option></option>")
                                     .attr("value", value.s_name).text(value.s_name));
                                });
                                $("#sRegion").attr("value", $("#regionId option[value='"+actualRegionId+"']").text());
                            },
                            dataType: "json"
                        });
                    }
                });

Thank you all

*

MB Themes

Re: The problem of the language of cities appears only in English
« Reply #5 on: August 01, 2021, 09:26:26 AM »
@7ala
Read the docs first please, then ask, not vice versa.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

7ala

  • ****
  • 144 posts
Re: The problem of the language of cities appears only in English
« Reply #6 on: August 01, 2021, 09:02:30 PM »
In this code I changed this
Code: [Select]
<option value="<?php echo $region['s_name'] ; ?>"><?php echo osc_location_native_name_selector($region) ; ?></option>
But here the situation is different
Code: [Select]
<select id="sCity" name="sCity" >
                                <option value=""><?php _e('Select a City...''eva'); ?></option>
                            </select>
Change I think here
Code: [Select]
.attr("value", value.s_name).text(value.s_name));It's here, but I tried, but I couldn't find a solution
I changed it to
  var vname = data[key].s_name;
Code: [Select]
.attr("value", value.vname).text(value.vname));
Unfortunately, I did not find a solution

I read the document
But I couldn't find a solution
Thanks

*

MB Themes

Re: The problem of the language of cities appears only in English
« Reply #7 on: August 02, 2021, 09:29:39 AM »
@7ala
There is key to success:
Code: [Select]
success: function(data){
  var length = data.length;
  var locationsNative = "<?php echo osc_get_current_user_locations_native(); ?>";

  if(length > 0) {
    result += '<option selected value=""><?php echo osc_esc_js(__'Select a region...' )); ?></option>';
    for(key in data) {
      var vname = data[key].s_name;
      if(data[key].hasOwnProperty('s_name_native')) {
          if(data[key].s_name_native != '' && locationsNative == "1") {
              vname = data[key].s_name_native;
          }
      }

      result += '<option value="' + data[key].pk_i_id + '">' + vname + '</option>';
    }
   
    ...
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

7ala

  • ****
  • 144 posts
Re: The problem of the language of cities appears only in English
« Reply #8 on: August 02, 2021, 03:07:54 PM »
please
I can't find this code
Code: [Select]
success: function(data){
  var length = data.length;

  if(length > 0) {
    result += '<option selected value=""><?php echo osc_esc_js(__'Select a region...' )); ?></option>';
    for(key in data) {
      result += '<option value="' + data[key].pk_i_id + '">' + data[key].s_name + '</option>'
    }
   
    ...
To replace it with this
Code: [Select]
success: function(data){
  var length = data.length;
  var locationsNative = "<?php echo osc_get_current_user_locations_native(); ?>";

  if(length > 0) {
    result += '<option selected value=""><?php echo osc_esc_js(__'Select a region...' )); ?></option>';
    for(key in data) {
      var vname = data[key].s_name;
      if(data[key].hasOwnProperty('s_name_native')) {
          if(data[key].s_name_native != '' && locationsNative == "1") {
              vname = data[key].s_name_native;
          }
      }

      result += '<option value="' + data[key].pk_i_id + '">' + vname + '</option>';
    }
   
    ...
I searched a lot
I did not find a solution where can I find its location in any file
Thanks

*

MB Themes

Re: The problem of the language of cities appears only in English
« Reply #9 on: August 03, 2021, 09:11:29 AM »
@7ala
It is pattern for solution.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

7ala

  • ****
  • 144 posts
Re: The problem of the language of cities appears only in English
« Reply #10 on: August 05, 2021, 01:27:16 PM »
I came up with a solution
This has been changed
Code: [Select]
.attr("value", value.s_name).text(value.s_name));by this
Code: [Select]
.attr("value", value.s_name_native).text(value.s_name_native));But a new problem appeared :'( :'(
Cities appear in the translated language, even if the language of the site is changed to English
It only appears in the translated language
I don't know what's wrong :-[ :-[ :-[ :-[ :-[

I found this code site
Code: [Select]
success: function(data){
  var length = data.length;
  var locationsNative = "<?php echo osc_get_current_user_locations_native(); ?>";

  if(length > 0) {
    result += '<option selected value=""><?php echo osc_esc_js(__'Select a region...' )); ?></option>';
    for(key in data) {
      var vname = data[key].s_name;
      if(data[key].hasOwnProperty('s_name_native')) {
          if(data[key].s_name_native != '' && locationsNative == "1") {
              vname = data[key].s_name_native;
          }
      }

      result += '<option value="' + data[key].pk_i_id + '">' + vname + '</option>';
    }
It is on this path
oc-includes\osclass\frm\Item.form.class.php
in line 1238
Already exists
Because I have the latest Osclass v4.4.0
« Last Edit: August 05, 2021, 01:44:26 PM by 7ala »

*

osclassic

  • ***
  • 34 posts
Re: The problem of the language of cities appears only in English
« Reply #11 on: August 11, 2021, 03:40:11 AM »
What about using google translation for languages? I don't know much about it but I have seen a dropdown on some sites where the entire page gets translated instead of osclass languages which depends upon templates and always a lot of the stuff stays in English . Any feedback?

*

MB Themes

Re: The problem of the language of cities appears only in English
« Reply #12 on: August 11, 2021, 08:51:54 AM »
@osclassic
There are simple modifications those help you to achieve such translator, but in general it is very user unfriendly solution.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots