Skip to content

Commit

Permalink
Merge pull request #6929 from ChurchCRM/locale/new-locales-4-2024
Browse files Browse the repository at this point in the history
Locale Cleanup
  • Loading branch information
DawoudIO authored Apr 6, 2024
2 parents e9eccf0 + 7039ac5 commit f034bea
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 23 deletions.
41 changes: 20 additions & 21 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -501,42 +501,41 @@ module.exports = function (grunt) {
grunt.registerTask('genLocaleJSFiles', '', function () {
var locales = grunt.file.readJSON("src/locale/locales.json");
for (var key in locales ) {
var localeConfig = locales[key];
var locale = localeConfig["locale"];
var countryCode = localeConfig["countryCode"];
var languageCode = localeConfig["languageCode"];
var enableFullCalendar = localeConfig["fullCalendar"];
var enableDatePicker = localeConfig["datePicker"];
var enableSelect2 = localeConfig["select2"];
let localeConfig = locales[key];
let locale = localeConfig["locale"];
let languageCode = localeConfig["languageCode"];
let enableFullCalendar = localeConfig["fullCalendar"];
let enableDatePicker = localeConfig["datePicker"];
let enableSelect2 = localeConfig["select2"];

var tempFile = 'locale/JSONKeys/'+locale+'.json';
var poTerms = grunt.file.read(tempFile);
if (poTerms == "") {
let tempFile = 'locale/JSONKeys/'+locale+'.json';
let poTerms = grunt.file.read(tempFile);
if (poTerms === "") {
poTerms = "{}";
}
var jsFileContent = '// Source: ' + tempFile;
jsFileContent = jsFileContent + "\ntry {window.CRM.i18keys = " + poTerms + ";} catch(e) {};\n";
let jsFileContent = '// Source POEditor: ' + tempFile;
jsFileContent = jsFileContent + "\ntry {window.CRM.i18keys = " + poTerms + ";} catch(e) {}\n";

if (enableFullCalendar) {
var tempLangCode = languageCode.toLowerCase();
let tempLangCode = languageCode.toLowerCase();
if (localeConfig.hasOwnProperty("fullCalendarLocale")) {
tempLangCode = localeConfig["fullCalendarLocale"];
}
tempFile = 'node_modules/@fullcalendar/core/locales/'+tempLangCode+'.js';
var fullCalendar = grunt.file.read(tempFile);
jsFileContent = jsFileContent + '\n// Source: ' + tempFile;
jsFileContent = jsFileContent + '\n' + "try {"+fullCalendar+"} catch(e) {};\n";
let fullCalendar = grunt.file.read(tempFile);
jsFileContent = jsFileContent + '\n// Source fullcalendar: ' + tempFile;
jsFileContent = jsFileContent + '\n' + "try {"+fullCalendar+"} catch(e) {}\n";
}
if (enableDatePicker) {
tempFile = 'node_modules/bootstrap-datepicker/dist/locales/bootstrap-datepicker.'+languageCode+'.min.js';
var datePicker = grunt.file.read(tempFile);
jsFileContent = jsFileContent + '\n// Source: ' + tempFile;
jsFileContent = jsFileContent + '\n' + "try {"+datePicker+"} catch(e) {};\n"
let datePicker = grunt.file.read(tempFile);
jsFileContent = jsFileContent + '\n// Source datepicker: ' + tempFile;
jsFileContent = jsFileContent + '\n' + "try {"+datePicker+"} catch(e) {}\n"
}
if (enableSelect2) {
tempFile = 'node_modules/select2/dist/js/i18n/'+languageCode+'.js';
jsFileContent = jsFileContent + '\n// Source: ' + tempFile;
var select2 = grunt.file.read(tempFile);
jsFileContent = jsFileContent + '\n// Source select2: ' + tempFile;
let select2 = grunt.file.read(tempFile);
jsFileContent = jsFileContent + '\n' + "try {"+select2+"} catch(e) {}"
}
grunt.file.write('src/locale/js/'+locale+'.js', jsFileContent );
Expand Down
3 changes: 1 addition & 2 deletions src/Include/Footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,13 @@
<script src="<?= SystemURLs::getRootPath() ?>/skin/external/fastclick/fastclick.js"></script>
<script src="<?= SystemURLs::getRootPath() ?>/skin/external/bootstrap-toggle/bootstrap-toggle.js"></script>
<script src="<?= SystemURLs::getRootPath() ?>/skin/external/i18next/i18next.min.js"></script>
<script src="<?= SystemURLs::getRootPath() ?>/locale/js/<?= Bootstrapper::getCurrentLocale()->getLocale() ?>.js"></script>
<script src="<?= SystemURLs::getRootPath() ?>/skin/external/bootstrap-validator/validator.min.js"></script>

<script src="<?= SystemURLs::getRootPath() ?>/skin/js/IssueReporter.js"></script>
<script src="<?= SystemURLs::getRootPath() ?>/skin/js/DataTables.js"></script>
<script src="<?= SystemURLs::getRootPath() ?>/skin/js/Events.js"></script>
<script src="<?= SystemURLs::getRootPath() ?>/skin/js/Footer.js"></script>

<script src="<?= SystemURLs::getRootPath() ?>/locale/js/<?= Bootstrapper::getCurrentLocale()->getLocale() ?>.js"></script>
<?php if (isset($sGlobalMessage)) {
?>
<script nonce="<?= SystemURLs::getCSPNonce() ?>">
Expand Down

0 comments on commit f034bea

Please sign in to comment.