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