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