Merge pull request #15390 from kewljuice/patch-4
[civicrm-core.git] / templates / CRM / common / l10n.js.tpl
1 {*
2 +--------------------------------------------------------------------+
3 | Copyright CiviCRM LLC. All rights reserved. |
4 | |
5 | This work is published under the GNU AGPLv3 license with some |
6 | permitted exceptions and without any warranty. For full license |
7 | and copyright information, see https://civicrm.org/licensing |
8 +--------------------------------------------------------------------+
9 *}// http://civicrm.org/licensing
10 // <script> Generated {$smarty.now|date_format:'%d %b %Y %H:%M:%S'}
11 {* This file should only contain strings and settings which rarely change *}
12 (function($) {ldelim}
13 // Config settings
14 CRM.config.userFramework = {$config->userFramework|@json_encode};
15 CRM.config.resourceBase = {$config->userFrameworkResourceURL|@json_encode};
16 CRM.config.packagesBase = {capture assign=packagesBase}{crmResURL expr='[civicrm.packages]/.'}{/capture}{$packagesBase|@json_encode};
17 CRM.config.lcMessages = {$config->lcMessages|@json_encode};
18 CRM.config.locale = {$locale|@json_encode};
19 CRM.config.cid = {$cid|@json_encode};
20 $.datepicker._defaults.dateFormat = CRM.config.dateInputFormat = {$config->dateInputFormat|@json_encode};
21 CRM.config.timeIs24Hr = {if $config->timeInputFormat eq 2}true{else}false{/if};
22 CRM.config.ajaxPopupsEnabled = {$ajaxPopupsEnabled|@json_encode};
23 CRM.config.allowAlertAutodismissal = {$allowAlertAutodismissal|@json_encode};
24 CRM.config.resourceCacheCode = {$resourceCacheCode|@json_encode};
25
26 // Merge entityRef settings
27 CRM.config.entityRef = $.extend({ldelim}{rdelim}, {$entityRef|@json_encode}, CRM.config.entityRef || {ldelim}{rdelim});
28
29 // Initialize CRM.url and CRM.formatMoney
30 CRM.url({ldelim}back: '{crmURL p="civicrm-placeholder-url-path" q="civicrm-placeholder-url-query=1" h=0 fb=1}', front: '{crmURL p="civicrm-placeholder-url-path" q="civicrm-placeholder-url-query=1" h=0 fe=1}'{rdelim});
31 CRM.formatMoney('init', false, {$moneyFormat});
32
33 // Localize select2
34 $.fn.select2.defaults.formatNoMatches = "{ts escape='js'}None found.{/ts}";
35 $.fn.select2.defaults.formatLoadMore = "{ts escape='js'}Loading...{/ts}";
36 $.fn.select2.defaults.formatSearching = "{ts escape='js'}Searching...{/ts}";
37 $.fn.select2.defaults.formatInputTooShort = function() {ldelim}
38 return ($(this).data('api-entity') === 'contact' || $(this).data('api-entity') === 'Contact') ? {$contactSearch} : {$otherSearch};
39 {rdelim};
40
41 // Localize jQuery UI
42 $.ui.dialog.prototype.options.closeText = "{ts escape='js'}Close{/ts}";
43
44 // Localize jQuery DataTables
45 // Note the first two defaults set here aren't localization related,
46 // but need to be set globally for all DataTables.
47 $.extend( $.fn.dataTable.defaults, {ldelim}
48 "searching": false,
49 "jQueryUI": true,
50 "language": {ldelim}
51 "emptyTable": "{ts escape='js'}None found.{/ts}",
52 "info": "{ts escape='js' 1=_START_ 2=_END_ 3=_TOTAL_}Showing %1 to %2 of %3 entries{/ts}",
53 "infoEmpty": "{ts escape='js'}Showing 0 to 0 of 0 entries{/ts}",
54 "infoFiltered": "{ts escape='js' 1=_MAX_}(filtered from %1 total entries){/ts}",
55 "infoPostFix": "",
56 "thousands": {$config->monetaryThousandSeparator|json_encode},
57 "lengthMenu": "{ts escape='js' 1=_MENU_}Show %1 entries{/ts}",
58 "loadingRecords": " ",
59 "processing": " ",
60 "zeroRecords": "{ts escape='js'}None found.{/ts}",
61 "paginate": {ldelim}
62 "first": "{ts escape='js'}First{/ts}",
63 "last": "{ts escape='js'}Last{/ts}",
64 "next": "{ts escape='js'}Next{/ts}",
65 "previous": "{ts escape='js'}Previous{/ts}"
66 {rdelim}
67 {rdelim}
68 {rdelim});
69
70 // Localize strings for jQuery.validate
71 var messages = {ldelim}
72 required: "{ts escape='js'}This field is required.{/ts}",
73 remote: "{ts escape='js'}Please fix this field.{/ts}",
74 email: "{ts escape='js'}Please enter a valid email address.{/ts}",
75 url: "{ts escape='js'}Please enter a valid URL.{/ts}",
76 date: "{ts escape='js'}Please enter a valid date.{/ts}",
77 dateISO: "{ts escape='js'}Please enter a valid date (YYYY-MM-DD).{/ts}",
78 number: "{ts escape='js'}Please enter a valid number.{/ts}",
79 digits: "{ts escape='js'}Please enter only digits.{/ts}",
80 creditcard: "{ts escape='js'}Please enter a valid credit card number.{/ts}",
81 equalTo: "{ts escape='js'}Please enter the same value again.{/ts}",
82 accept: "{ts escape='js'}Please enter a value with a valid extension.{/ts}",
83 maxlength: $.validator.format("{ts escape='js'}Please enter no more than {ldelim}0{rdelim} characters.{/ts}"),
84 minlength: $.validator.format("{ts escape='js'}Please enter at least {ldelim}0{rdelim} characters.{/ts}"),
85 rangelength: $.validator.format("{ts escape='js'}Please enter a value between {ldelim}0{rdelim} and {ldelim}1{rdelim} characters long.{/ts}"),
86 range: $.validator.format("{ts escape='js'}Please enter a value between {ldelim}0{rdelim} and {ldelim}1{rdelim}.{/ts}"),
87 max: $.validator.format("{ts escape='js'}Please enter a value less than or equal to {ldelim}0{rdelim}.{/ts}"),
88 min: $.validator.format("{ts escape='js'}Please enter a value greater than or equal to {ldelim}0{rdelim}.{/ts}")
89 };
90 $.extend($.validator.messages, messages);
91 {literal}
92
93 var params = {
94 errorClass: 'crm-inline-error',
95 messages: {},
96 // TODO: remove after resolution of https://github.com/jzaefferer/jquery-validation/pull/1261
97 ignore: ":hidden, [readonly]"
98 };
99
100 // use civicrm notifications when there are errors
101 params.invalidHandler = function(form, validator) {
102 // If there is no container for display then red text will still show next to the invalid fields
103 // but there will be no overall message. Currently the container is only available on backoffice pages.
104 if ($('#crm-notification-container').length) {
105 $.each(validator.errorList, function(k, error) {
106 $(error.element).crmError(error.message);
107 });
108 }
109 };
110
111 CRM.validate = {
112 _defaults: params,
113 params: {},
114 functions: []
115 };
116
117 // Load polyfill
118 if (!('Promise' in window)) {
119 CRM.loadScript(CRM.config.resourceBase + 'bower_components/es6-promise/es6-promise.auto.min.js');
120 }
121
122 })(jQuery);
123 {/literal}