Osclass forums
Support forums => Themes => Twitter => Topic started by: Lasse 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 ?
-
jquery-ui.js
Don't know what is wrong in the 2nd question.
-
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.
-
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> <span class="ui-datepicker-year">2014</span></div></div>
-
Hi,
Let's see if these two resources may help you:
http://jqueryui.com/datepicker/#localization (http://jqueryui.com/datepicker/#localization)
http://code.google.com/p/jquery-ui/source/browse/trunk/ui/i18n/ui.datepicker-sv.js?r=3004&spec=svn3034 (http://code.google.com/p/jquery-ui/source/browse/trunk/ui/i18n/ui.datepicker-sv.js?r=3004&spec=svn3034)
Regards
-
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 ?
-
***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:
<?php if (osc_current_user_locale() == 'se_SE') { ?
<script type="text/javascript">
[the script here]
</script>
?>
Regards
-
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 )
-
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:
<?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
-
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 ?
-
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
-
***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:
<div id="custom_fields">
<?php if( osc_count_item_meta() >= 1 ) { ?>
<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:
<div id="custom_fields">
<?php if( osc_count_item_meta() >= 1 ) { ?>
<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
-
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>
-
***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:
<div class="custom_fields">
<?php if( osc_count_item_meta() > 0 ) { ?>
<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
-
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
-
I`m sorry.... First I tryed with the script in the footer.php with se_SE insted of se-SE, but that only gave me the calender in english again. Then I loaded the search.php and item-post.php and item-edit.php with only the script part betwen the header tags again and that brought back the swedish spelling in the calendar. Then I switched the code in the item.php against the new code string that you wrote teseo, but the name of the months still comes out in English when the ads are shown :(
Lasse
-
Ups, I forgot to change a line:
<font color="#822619"> <strong><?php echo osc_item_meta_name() ; ?>: <?php echo osc_item_meta_value() ; ?></strong></font>
now should be:
<font color="#822619"> <strong><?php echo osc_item_meta_name() ; ?>: <?php echo $meta_value ; ?></strong></font>
Regards
-
I just got one thing to say; Batman and Superman, go home ! Becouse I have a new Hero, and his/hers name is teseo !! :)
It works like a charm ! Thanks teseo ! :)
Lasse
-
You seem to keep your promises, @lasse... :D :D You're welcome. :) Would you consider to change the name of this thread to something like "Translation for DATE and DATEINTERVAL custom fields [SOLVED]" so it could be useful to other fellows in the same situation? Thanks.
I think that the key error here is the se-SE, it should be written with underscore se_SE.
Yes, @dev101, a typo of mine. As I know you're working along with the Osclass developers, I think I should note here that seems translations of these DATE and DATEINTERVAL should be managed by default by osc_item_meta_value() in hItems.php. The code is there, but looks like the returned results are no the desired ones. ???
For instance, for DATE type, this:
return htmlentities( date(osc_date_format(), $value), ENT_COMPAT, "UTF-8");
returns formatted correct date, but in english.
This:
return osc_format_date(date("Y-m-d", $value));
would return formatted correct date in the active language.
If you deem worthy of it to study this issue and propose changes in GitHub, I would be most grateful, unfortunately my scarce free time I spend it this way, here on the forum. Thanks in advance. :)
Regards
-
As I know you're working along with the Osclass developers (...)
Hey, hey, let's not exaggerate here, shall we? ;D
I am helping as much as I can, like everyone else, 'working' is a bit of a too strong word IMO. I am writing this because each month I receive many PMs with various questions and requests that I cannot possibly fulfill.
Just on the ground :)
Regards
-
I have done a test with sv_SE and Bender with 341, and as far as date picker is in question, this codes 1 (http://forums.osclass.org/twitter/jquary-names-for-days-and-months/msg103417/#msg103417)+2 (http://forums.osclass.org/twitter/jquary-names-for-days-and-months/msg103472/#msg103472) works fine (once you correct sv-SE part), without any modifications that followed.
However, notice that once date is selected, word inputs are in english, not sure why and if the above modifications solves that part, but frankly can't dwell into that right now - works good enough :D