stas131095's picture
Переведи разделы сайта на Русский язык
456e1a2 verified
Raw History Blame Contribute Delete
8.05 kB
// Translation dictionary
const translations = {
en: {
// English translations
},
ru: {
"C++ Code Crusaders Adventure": "C++ Код Крестоносцы Приключение",
"Embark on an epic journey to master the fundamentals of C++ programming!": "Отправьтесь в эпическое путешествие, чтобы освоить основы программирования на C++!",
"Getting Started": "Начало работы",
"Learn the basic syntax, variables, and data types in C++.": "Изучите базовый синтаксис, переменные и типы данных в C++.",
"Start Learning": "Начать обучение",
"Control Structures": "Управляющие конструкции",
"Master loops, conditionals, and program flow control.": "Освойте циклы, условия и управление потоком программы.",
"Functions & OOP": "Функции и ООП",
"Discover functions, classes, and object-oriented programming.": "Откройте для себя функции, классы и объектно-ориентированное программирование.",
"Ready to Test Your Knowledge?": "Готовы проверить свои знания?",
"After completing all lessons, challenge yourself with our interactive quiz to reinforce what you've learned!": "После завершения всех уроков проверьте себя с помощью нашего интерактивного теста, чтобы закрепить полученные знания!",
"Take the Quiz": "Пройти тест",
"Progress:": "Прогресс:",
"Back": "Назад",
"Mark Complete": "Отметить завершенным",
"Next:": "Далее:",
"Submit Quiz": "Отправить тест",
"Quiz Results": "Результаты теста",
"Excellent work! You've mastered the C++ fundamentals!": "Отличная работа! Вы освоили основы C++!",
"Good job! You have a solid understanding of C++ basics.": "Хорошая работа! У вас прочные знания основ C++.",
"Not bad! Review the lessons to improve your understanding.": "Неплохо! Повторите уроки для лучшего понимания.",
"Keep practicing! Review the lessons and try again.": "Продолжайте практиковаться! Повторите уроки и попробуйте снова.",
"Home": "Главная",
"Review": "Повторить",
"Conditional Statements": "Условные операторы",
"Control structures allow you to control the flow of execution in your program based on certain conditions.": "Управляющие конструкции позволяют контролировать поток выполнения программы на основе определенных условий.",
"If-Else Statements": "Операторы If-Else",
"Switch Statements": "Оператор Switch",
"Loops": "Циклы",
"For Loop": "Цикл For",
"While Loop": "Цикл While",
"Functions in C++": "Функции в C++",
"Functions allow you to group code into reusable blocks. They can take parameters and return values.": "Функции позволяют группировать код в повторно используемые блоки. Они могут принимать параметры и возвращать значения.",
"Function Example": "Пример функции",
"Object-Oriented Programming": "Объектно-ориентированное программирование",
"C++ supports object-oriented programming with classes and objects.": "C++ поддерживает объектно-ориентированное программирование с классами и объектами.",
"Class Example": "Пример класса",
"Inheritance Example": "Пример наследования",
"1. What is the correct syntax to output \"Hello World\" in C++?": "1. Какой правильный синтаксис для вывода \"Hello World\" в C++?",
"2. Which of the following is NOT a valid C++ data type?": "2. Какой из следующих типов данных НЕ является допустимым в C++?",
"3. What is the correct way to create a for loop in C++?": "3. Как правильно создать цикл for в C++?",
"4. How do you declare a function in C++ that doesn't return any value?": "4. Как объявить функцию в C++, которая не возвращает значение?",
"5. Which keyword is used to create a class in C++?": "5. Какое ключевое слово используется для создания класса в C++?",
"Correct! Well done!": "Правильно! Отличная работа!",
"Incorrect. Try again!": "Неверно. Попробуйте еще раз!"
}
};
// Shared JavaScript functionality
document.addEventListener('DOMContentLoaded', function() {
// Set language
const lang = localStorage.getItem('lang') || 'en';
document.documentElement.lang = lang;
// Apply translations
if (lang === 'ru') {
const elements = document.querySelectorAll('[data-translate]');
elements.forEach(el => {
const key = el.dataset.translate;
if (translations.ru[key]) {
el.textContent = translations.ru[key];
}
});
}
// Initialize tooltips
const tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'));
tooltipTriggerList.map(function (tooltipTriggerEl) {
return new bootstrap.Tooltip(tooltipTriggerEl);
});
// Progress tracking
if (localStorage.getItem('cppProgress')) {
const progress = JSON.parse(localStorage.getItem('cppProgress'));
updateProgressBars(progress);
}
});
function updateProgressBars(progress) {
const progressBars = document.querySelectorAll('.progress-fill');
progressBars.forEach(bar => {
const section = bar.dataset.section;
if (progress[section]) {
bar.style.width = `${progress[section]}%`;
}
});
}
function markSectionComplete(section) {
let progress = localStorage.getItem('cppProgress') ? JSON.parse(localStorage.getItem('cppProgress')) : {};
progress[section] = 100;
localStorage.setItem('cppProgress', JSON.stringify(progress));
updateProgressBars(progress);
}
// Quiz functionality
function checkAnswer(questionId, correctAnswer) {
const selectedOption = document.querySelector(`input[name="${questionId}"]:checked`);
if (!selectedOption) return false;
const feedbackElement = document.getElementById(`feedback-${questionId}`);
if (selectedOption.value === correctAnswer) {
feedbackElement.textContent = "Correct! Well done!";
feedbackElement.className = "text-green-600 mt-2";
return true;
} else {
feedbackElement.textContent = "Incorrect. Try again!";
feedbackElement.className = "text-red-600 mt-2";
return false;
}
}
function calculateQuizScore() {
const questions = document.querySelectorAll('.quiz-question');
let correctAnswers = 0;
questions.forEach(question => {
const questionId = question.id;
const correctAnswer = question.dataset.correctAnswer;
if (checkAnswer(questionId, correctAnswer)) {
correctAnswers++;
}
});
const scorePercentage = Math.round((correctAnswers / questions.length) * 100);
return scorePercentage;
}