Merge in 5.11
[civicrm-core.git] / templates / CRM / common / l10n.js.tpl
CommitLineData
b7ceb253 1{*
3d527838 2 +--------------------------------------------------------------------+
fee14197 3 | CiviCRM version 5 |
3d527838 4 +--------------------------------------------------------------------+
6b83d5bd 5 | Copyright CiviCRM LLC (c) 2004-2019 |
3d527838
CW
6 +--------------------------------------------------------------------+
7 | This file is a part of CiviCRM. |
8 | |
9 | CiviCRM is free software; you can copy, modify, and distribute it |
10 | under the terms of the GNU Affero General Public License |
11 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
12 | |
13 | CiviCRM is distributed in the hope that it will be useful, but |
14 | WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
16 | See the GNU Affero General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU Affero General Public |
19 | License and the CiviCRM Licensing Exception along |
20 | with this program; if not, contact CiviCRM LLC |
21 | at info[AT]civicrm[DOT]org. If you have questions about the |
22 | GNU Affero General Public License or the licensing of CiviCRM, |
23 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
24 +--------------------------------------------------------------------+
25*}// http://civicrm.org/licensing
51b81901 26// <script> Generated {$smarty.now|date_format:'%d %b %Y %H:%M:%S'}
4e56e743 27{* This file should only contain strings and settings which rarely change *}
3d527838 28(function($) {ldelim}
4e56e743
CW
29 // Config settings
30 CRM.config.userFramework = {$config->userFramework|@json_encode};
dc662c39 31 CRM.config.resourceBase = {$config->userFrameworkResourceURL|@json_encode};
4e56e743 32 CRM.config.lcMessages = {$config->lcMessages|@json_encode};
b30809e4
CW
33 CRM.config.locale = {$locale|@json_encode};
34 CRM.config.cid = {$cid|@json_encode};
af3775b3
CW
35 $.datepicker._defaults.dateFormat = CRM.config.dateInputFormat = {$config->dateInputFormat|@json_encode};
36 CRM.config.timeIs24Hr = {if $config->timeInputFormat eq 2}true{else}false{/if};
7b83e312 37 CRM.config.ajaxPopupsEnabled = {$ajaxPopupsEnabled|@json_encode};
a9fb6123 38 CRM.config.allowAlertAutodismissal = {$allowAlertAutodismissal|@json_encode};
c7e39a79 39 CRM.config.resourceCacheCode = {$resourceCacheCode|@json_encode};
4e56e743 40
b7ceb253
CW
41 // Merge entityRef settings
42 CRM.config.entityRef = $.extend({ldelim}{rdelim}, {$entityRef|@json_encode}, CRM.config.entityRef || {ldelim}{rdelim});
6ef865c6 43
3d527838 44 // Initialize CRM.url and CRM.formatMoney
f0c9c7dd 45 CRM.url({ldelim}back: '{crmURL p="*path*" q="*query*" h=0 fb=1}', front: '{crmURL p="*path*" q="*query*" h=0 fe=1}'{rdelim});
7f92cfa9 46 CRM.formatMoney('init', false, {$moneyFormat});
3d527838
CW
47
48 // Localize select2
49 $.fn.select2.defaults.formatNoMatches = "{ts escape='js'}None found.{/ts}";
50 $.fn.select2.defaults.formatLoadMore = "{ts escape='js'}Loading...{/ts}";
51 $.fn.select2.defaults.formatSearching = "{ts escape='js'}Searching...{/ts}";
52 $.fn.select2.defaults.formatInputTooShort = function() {ldelim}
b3d31cda 53 return ($(this).data('api-entity') === 'contact' || $(this).data('api-entity') === 'Contact') ? {$contactSearch} : {$otherSearch};
3d527838
CW
54 {rdelim};
55
6ef865c6
CW
56 // Localize jQuery UI
57 $.ui.dialog.prototype.options.closeText = "{ts escape='js'}Close{/ts}";
58
7d12de7f
JL
59 // Localize jQuery DataTables
60 // Note the first two defaults set here aren't localization related,
61 // but need to be set globally for all DataTables.
62 $.extend( $.fn.dataTable.defaults, {ldelim}
63 "searching": false,
64 "jQueryUI": true,
65 "language": {ldelim}
66 "emptyTable": "{ts escape='js'}None found.{/ts}",
3fff685f 67 "info": "{ts escape='js' 1=_START_ 2=_END_ 3=_TOTAL_}Showing %1 to %2 of %3 entries{/ts}",
7d12de7f
JL
68 "infoEmpty": "{ts escape='js'}Showing 0 to 0 of 0 entries{/ts}",
69 "infoFiltered": "{ts escape='js' 1=_MAX_}(filtered from %1 total entries){/ts}",
70 "infoPostFix": "",
71 "thousands": {$config->monetaryThousandSeparator|json_encode},
72 "lengthMenu": "{ts escape='js' 1=_MENU_}Show %1 entries{/ts}",
73 "loadingRecords": " ",
74 "processing": " ",
75 "zeroRecords": "{ts escape='js'}None found.{/ts}",
76 "paginate": {ldelim}
77 "first": "{ts escape='js'}First{/ts}",
78 "last": "{ts escape='js'}Last{/ts}",
79 "next": "{ts escape='js'}Next{/ts}",
80 "previous": "{ts escape='js'}Previous{/ts}"
81 {rdelim}
82 {rdelim}
83 {rdelim});
84
3d527838
CW
85 // Localize strings for jQuery.validate
86 var messages = {ldelim}
87 required: "{ts escape='js'}This field is required.{/ts}",
88 remote: "{ts escape='js'}Please fix this field.{/ts}",
89 email: "{ts escape='js'}Please enter a valid email address.{/ts}",
90 url: "{ts escape='js'}Please enter a valid URL.{/ts}",
91 date: "{ts escape='js'}Please enter a valid date.{/ts}",
92 dateISO: "{ts escape='js'}Please enter a valid date (YYYY-MM-DD).{/ts}",
93 number: "{ts escape='js'}Please enter a valid number.{/ts}",
94 digits: "{ts escape='js'}Please enter only digits.{/ts}",
95 creditcard: "{ts escape='js'}Please enter a valid credit card number.{/ts}",
96 equalTo: "{ts escape='js'}Please enter the same value again.{/ts}",
97 accept: "{ts escape='js'}Please enter a value with a valid extension.{/ts}",
98 maxlength: $.validator.format("{ts escape='js'}Please enter no more than {ldelim}0{rdelim} characters.{/ts}"),
99 minlength: $.validator.format("{ts escape='js'}Please enter at least {ldelim}0{rdelim} characters.{/ts}"),
100 rangelength: $.validator.format("{ts escape='js'}Please enter a value between {ldelim}0{rdelim} and {ldelim}1{rdelim} characters long.{/ts}"),
101 range: $.validator.format("{ts escape='js'}Please enter a value between {ldelim}0{rdelim} and {ldelim}1{rdelim}.{/ts}"),
102 max: $.validator.format("{ts escape='js'}Please enter a value less than or equal to {ldelim}0{rdelim}.{/ts}"),
103 min: $.validator.format("{ts escape='js'}Please enter a value greater than or equal to {ldelim}0{rdelim}.{/ts}")
104 };
105 $.extend($.validator.messages, messages);
106 {literal}
107
108 var params = {
109 errorClass: 'crm-inline-error',
8947862b
CW
110 messages: {},
111 // TODO: remove after resolution of https://github.com/jzaefferer/jquery-validation/pull/1261
112 ignore: ":hidden, [readonly]"
3d527838
CW
113 };
114
115 // use civicrm notifications when there are errors
116 params.invalidHandler = function(form, validator) {
117 if ($('#crm-notification-container').length) {
118 $.each(validator.errorList, function(k, error) {
119 $(error.element).crmError(error.message);
120 });
121 } else {
122 alert({/literal}"{ts escape='js'}Please review and correct the highlighted fields before continuing.{/ts}"{literal});
123 }
124 };
125
126 CRM.validate = {
127 _defaults: params,
128 params: {},
129 functions: []
130 };
131})(jQuery);
132{/literal}