Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Locale Cleanup #6929

Merged
merged 16 commits into from
Apr 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading