Advertisement:

Author Topic: Translation for DATE and DATEINTERVAL custom fields [SOLVED]  (Read 4547 times)

Lasse

  • Newbie
  • *
  • Posts: 14
Translation for DATE and DATEINTERVAL custom fields [SOLVED]
« on: August 12, 2014, 01:44:14 am »
Hi Everybody
Could someone please tell me where to find the source code for the Jquary pop up calendrar ? Trying to change the names for the days and months to swedish, but I´m out of files to change now, I think..... When in Admin, and edit a page, the calendar is in swedish, but for the user, when adding an item, the calendar still is in english, but when the date is selected, the date becomes swedish in the fields. But then when the ad is saved, the date transforms back to english again... >:(

Also, when in Admin, I changed that the week should start with Monday, it only doeas that when the pop up calendar shows up in admin, the calendar for the user still starts with Sunday ?
« Last Edit: August 14, 2014, 03:23:56 pm by Lasse »

dev101

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2155
  • osclass.work
Re: Jquary, names for days and months
« Reply #1 on: August 12, 2014, 02:01:46 am »
jquery-ui.js

Don't know what is wrong in the 2nd question.

Lasse

  • Newbie
  • *
  • Posts: 14
Re: Jquary, names for days and months
« Reply #2 on: August 12, 2014, 10:20:32 am »
I´m sorry, but I have no file just called:  jquery-ui.js. There is one called jquery-ui.min.js in osclass/assets/js    but in that file there is no names written for days and months.

Lasse

  • Newbie
  • *
  • Posts: 14
Re: Jquary, names for days and months
« Reply #3 on: August 12, 2014, 09:40:36 pm »
This is the source of the pop up calendar ( I think  :) But where does it come from ??
I want to change : <span class="ui-datepicker-month">August</span> so it says Augusti instead.



<div class="ui-datepicker-header ui-widget-header ui-helper-clearfix ui-corner-all"><a class="ui-datepicker-prev ui-corner-all" data-handler="prev" data-event="click" title="Prev"><span class="ui-icon ui-icon-circle-triangle-w">Prev</span></a><a class="ui-datepicker-next ui-corner-all" data-handler="next" data-event="click" title="Next"><span class="ui-icon ui-icon-circle-triangle-e">Next</span></a><div class="ui-datepicker-title"><span class="ui-datepicker-month">August</span>&nbsp;<span class="ui-datepicker-year">2014</span></div></div>

teseo

  • Hero Member
  • *****
  • Posts: 6169

Lasse

  • Newbie
  • *
  • Posts: 14
Re: Jquary, names for days and months
« Reply #5 on: August 13, 2014, 02:30:10 am »
Thanks teseo ! I have made a js file of the code sorce from the second link you gave me, but I´m not sure where to put the file and if I have to make other changes somewhere else to make it active ?

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: Jquary, names for days and months
« Reply #6 on: August 13, 2014, 03:10:55 am »
***CORRECTED***

I've just added it at the bottom of theme footer.php between <script type="text/javascript"> [the script] </script> tags and the calendar is being shown in swedish. If you're using multilanguage (swedish/english for instance) just wrap it in a PHP conditional:


Code: [Select]
<?php if (osc_current_user_locale() == 'se_SE') { ?
    <
script type="text/javascript">

    [
the script here]

    
</script>

?>

Regards
« Last Edit: August 14, 2014, 01:28:22 pm by teseo »

Lasse

  • Newbie
  • *
  • Posts: 14
Re: Jquary, names for days and months
« Reply #7 on: August 13, 2014, 10:37:46 am »
Thanks again teseo, I´m one step closer to have it 100% right. It didn´t work for me to put it in the footer.php so I put only the script part in the head section of the pages item-post.php and search.php and now the calebdar dates are in Swedish ! :)

The only thing left to work on is that when the event has been saved, the ad still shows the name of the month in english  :(
(I´m using the page as an vehicle event clandar )

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: Jquary, names for days and months
« Reply #8 on: August 13, 2014, 01:09:17 pm »
The only thing left to work on is that when the event has been saved, the ad still shows the name of the month in english  :(

This is why I told you to put it in a script common to all pages and at a stage where main jQuery library has been loaded for sure (footer.php). My mistake was in this "added it at the bottom...", too generic, without specifying exact placement. It must be put before the HTML document is closed. So:

Code: [Select]
<?php osc_run_hook('footer'); ?>

<?php if (osc_current_user_locale() == 'se-SE') { ?>
    <script type="text/javascript">

    [the script here]

    </script>
<?php ?>

</body></html>

Regards

« Last Edit: August 13, 2014, 01:10:51 pm by teseo »

Lasse

  • Newbie
  • *
  • Posts: 14
Re: Jquary, names for days and months
« Reply #9 on: August 13, 2014, 04:34:09 pm »
Sorry, it dosn`t work at all if I do that. Perheps becouse the date fields isnt loading at the same as the page is loading, I have to click "choose categori" before the fields for the dates loads on the page  ??? Everyting works great when I put the script between the head tags, as I said before.
If I only could find out where the page gets the names for the months on the "view a item" page and was able to change the months names directly there, everything would be fine. Is it in my Mysql databas ?

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: Jquary, names for days and months
« Reply #10 on: August 13, 2014, 04:50:44 pm »
Oh, but in Item view UI Datepicker has nothing to do with the date formatting anymore. What you're facing is a general problem: custom fields are not being translated.

Give me a while and I'll see if I can find some reasonable solution. ???

Regards


teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: Jquary, names for days and months
« Reply #11 on: August 13, 2014, 05:10:05 pm »
***CORRECTED***

Here it is, this should work both for custom fields of type DATE and DATEINTERVAL (apparently they have some thing different) ??? The example code is for Bender theme.

Find this block in your item.php:

Code: [Select]
        <div id="custom_fields">
            <?php if( osc_count_item_meta() >= ) { ?>
                <br />
                <div class="meta_list">
                    <?php while ( osc_has_item_meta() ) { ?>
                        <?php if(osc_item_meta_value()!='') { ?>
                            <div class="meta">
                                <strong><?php echo osc_item_meta_name(); ?>:</strong> <?php echo osc_item_meta_value(); ?>
                            </div>
                        <?php ?>
                    <?php ?>
                </div>
            <?php ?>
        </div>

and replace it with:

Code: [Select]
        <div id="custom_fields">
            <?php if( osc_count_item_meta() >= ) { ?>
            <br />
            <div class="meta_list">
                <?php while ( osc_has_item_meta() ) { ?>
                <?php if(osc_item_meta_value()!='') {

                    
$meta = (View::newInstance()->_current('metafields'));
                    
$meta_value osc_item_meta_value();
                    if (
$meta['e_type'] == 'DATE'$meta_value osc_format_date($meta_value);
                    elseif (
$meta['e_type'] == 'DATEINTERVAL'$meta_value __('From') . ' ' osc_format_date(date("Y-m-d"$meta['s_value']['from'])) . ' ' __('to') . ' ' osc_format_date(date("Y-m-d"$meta['s_value']['to'])); ?>


                    <div class="meta">
                        <strong><?php echo osc_item_meta_name(); ?>:</strong> <?php echo $meta_value?>
                    </div>
                    <?php ?>
                <?php ?>
            </div>
            <?php ?>
        </div>

Regards
« Last Edit: August 13, 2014, 11:36:55 pm by teseo »

Lasse

  • Newbie
  • *
  • Posts: 14
Re: Jquary, names for days and months
« Reply #12 on: August 13, 2014, 09:00:23 pm »
Oh no, but date interval is what I´m using . I´m sorry if you spent a lot of time figuring this code out and now I cant use it  :-[
If you can change it so it works on date interval, then you will be my new Hero  ;D

Lasse

Ps. took a look at the code in my item.php and my code strings lokks like this, it´s not exactly the same as the first of yours ?
The font color is my own poking around in the script  ::)

<div class="custom_fields">
                        <?php if( osc_count_item_meta() > 0 ) { ?>
                        <div class="meta_list">
                            <?php while ( osc_has_item_meta() ) { ?>
                            <p class="meta no-margin">
                              <font color="#822619">  <strong><?php echo osc_item_meta_name() ; ?>: <?php echo osc_item_meta_value() ; ?></strong></font>
                            </p>
                            <?php } ?>
                        </div><p></p>
« Last Edit: August 13, 2014, 09:10:18 pm by Lasse »

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: Jquary, names for days and months
« Reply #13 on: August 13, 2014, 11:59:09 pm »
***CORRECTED***

Took me a while, DATE and DATEINTERVAL seem to have something different regarding their format. ???

I've corrected the above post (for Bender) and here it is adapted to your code:

Code: [Select]
<div class="custom_fields">
                        <?php if( osc_count_item_meta() > ) { ?>
                        <div class="meta_list">
                            <?php while ( osc_has_item_meta() ) { 

                            
$meta = (View::newInstance()->_current('metafields'));
                            
$meta_value osc_item_meta_value();
                            if (
$meta['e_type'] == 'DATE'$meta_value osc_format_date($meta_value);
                            elseif (
$meta['e_type'] == 'DATEINTERVAL'$meta_value __('From') . ' ' osc_format_date(date("Y-m-d"$meta['s_value']['from'])) . ' ' __('to') . ' ' osc_format_date(date("Y-m-d"$meta['s_value']['to'])); ?>


                            <p class="meta no-margin">
                              <font color="#822619">  <strong><?php echo osc_item_meta_name() ; ?>: <?php echo $meta_value ?></strong></font>
                            </p>
                            <?php ?>
                        </div><p></p>

Regards
« Last Edit: August 14, 2014, 02:29:01 am by teseo »

dev101

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2155
  • osclass.work
Re: Jquary, names for days and months
« Reply #14 on: August 14, 2014, 12:44:00 am »
I am really not sure why you have to go through so much trouble for this, in my case it is working perfectly fine without any mods.
I think that the key error here is the se-SE, it should be written with underscore se_SE.

Regards