Skip to content

Commit

Permalink
New language: Urdu (#548)
Browse files Browse the repository at this point in the history
* add urdu

Co-Authored-By: Asfandiyar Khan <[email protected]>

* fixes

* Add Urdu

* urdu styling

* Incognito support

* Update languages.js

refactor

* fix tool's favicon

---------

Co-authored-by: Asfandiyar Khan <[email protected]>
  • Loading branch information
prem-k-r and asfand-dev authored Feb 23, 2025
1 parent 902b786 commit af0a2da
Show file tree
Hide file tree
Showing 11 changed files with 674 additions and 458 deletions.
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Material You NewTab is a versatile browser extension that personalizes your New

<p align="center">
<a href="#-features">Features</a> •
<a href="#-currently-supported-languages-22">Currently Supported Languages</a> •
<a href="#-currently-supported-languages-23">Currently Supported Languages</a> •
<a href="#download">Download</a> •
<a href="#-installation-guide">Installation Guide</a>
<br>
Expand Down Expand Up @@ -167,7 +167,7 @@ For a step-by-step walkthrough, watch this [installation guide video](https://yo
[![Watch the video](https://img.youtube.com/vi/P4ryQPixfw8/0.jpg)](https://youtu.be/P4ryQPixfw8)
## 🌐 Currently Supported Languages (22)
## 🌐 Currently Supported Languages (23)
| Language | Code | Translator(s) |
| -------------------------------------------------------------------------------------------- | :---: | ------------------------------------------------------------------------------------- |
Expand All @@ -191,12 +191,14 @@ For a step-by-step walkthrough, watch this [installation guide video](https://yo
| <img src='https://flagcdn.com/si.svg' width=20> &nbsp; **Slovenian** - Slovenščina | sl-SI | [Linux-Alex](https://github.com/Linux-Alex/) |
| <img src='https://flagcdn.com/es.svg' width=20> &nbsp; **Spanish** - Español | es-ES | [XengShi](https://github.com/XengShi/) |
| <img src='https://flagcdn.com/tr.svg' width=20> &nbsp; **Turkish** - Türkçe | tr | [Nobody](https://github.com/Nobody9512), [Kerim Ölçer](https://github.com/kerimlcr) |
| <img src='https://flagcdn.com/pk.svg' width=20> &nbsp; **Urdu** - اردو | ur | [Asfandiyar Khan](https://github.com/asfand-dev) |
| <img src='https://flagcdn.com/uz.svg' width=20> &nbsp; **Uzbek** - O'zbek | uz | [Firdavs](https://github.com/Firdavs9512/) |
| <img src='https://flagcdn.com/vn.svg' width=20> &nbsp; **Vietnamese** - Tiếng Việt | vn | [Diep](https://github.com/diepdo1810/), [Tuan](https://github.com/Tuan1-2-3) |
Check the [Translation Status Page](https://xengshi.github.io/materialYouNewTab/tools/languagesAnalysis.html) for an overview of completed languages and missing strings analysis.
## 📖 Usage
<details>
<summary><h2>📖 Usage</h2></summary>
1. **Welcome Greeting**:
- The extension greets you with a personalized message, like "Hello! It’z RJ," and displays the current date. This feature can be customized in the settings to show your name or preferred text, making your browsing experience feel more personal.
Expand Down Expand Up @@ -256,6 +258,8 @@ Check the [Translation Status Page](https://xengshi.github.io/materialYouNewTab/
14. **Language Selector**:
- A language selector is included in the menu settings, enabling users to choose their preferred language for the extension interface.
- This feature supports multilingual customization, enhancing accessibility for users worldwide.
</details>
## 🤝 Contributing
Expand Down
4 changes: 3 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
<script src="locales/fr.js"></script>
<script src="locales/az.js"></script>
<script src="locales/sl.js"></script>
<script src="locales/ur.js"></script>

</head>

Expand Down Expand Up @@ -644,7 +645,7 @@ <h2 id="editBookmarkHeading">Edit Bookmark</h2>
</svg>

</div>
<span id="feelsLike" style="padding-inline-end: 12px;"></span>
<span id="feelsLike"></span>
</div>
<div class="tiles location">
<div class="icon">
Expand Down Expand Up @@ -1351,6 +1352,7 @@ <h1>Material You NewTab</h1>
<option value="sl">Slovenian (Slovenščina)</option>
<option value="es">Spanish (Español)</option>
<option value="tr">Turkish (Türkçe)</option>
<option value="ur">Urdu (اردو)</option>
<option value="uz">Uzbek (O'zbek)</option>
<option value="vi">Vietnamese (Tiếng Việt)</option>
<!-- Place new language alphabetically -->
Expand Down
8 changes: 4 additions & 4 deletions locales/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ const en = {
// Menu Items
"github": "GitHub",
"feedback": "Feedback",
"resetsettings": "Reset Settings",
"menuCloseText": "Close",

// Shortcuts
"shortcutsText": "Shortcuts",
Expand Down Expand Up @@ -131,11 +129,13 @@ const en = {
"enableDarkMode": "Dark Mode",
"enableDarkModeInfo": "Enable dark mode themes",

// Wallpaper and misc
// Wallpaper and settings
"uploadWallpaperText": "Upload Wallpaper", // Keep this short
"rangColor": "Pick color", // Keep this short
"backupText": "Backup",
"restoreText": "Restore",
"rangColor": "Pick color", // Keep this short
"resetsettings": "Reset Settings",
"menuCloseText": "Close",

// Dialog boxes (alerts)
"confirmWallpaper": "Would you like to set a new image as your wallpaper for the day?",
Expand Down
117 changes: 117 additions & 0 deletions locales/ur.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
// Urdu
const ur = {
// Menu Items
"github": "گٹ ہب",

// Shortcuts
"shortcutsInfoText": "انتخاب کریں کہ کون سے شارٹ کٹس دکھائے جائیں",
"editShortcutsList": "محفوظ کردہ شارٹ کٹس",
"editShortcutsListInfo": "آپ '+' آئیکن پر کلک کرکے نئے شارٹ کٹس شامل کرسکتے ہیں، یا موجودہ شارٹ کٹس کے نام یا یو آر ایل پر کلک کرکے ترمیم کرسکتے ہیں۔",
"adaptiveIconText": "موافقت پذیر آئیکن کی شکلیں",
"adaptiveIconInfoText": "شارٹ کٹ آئیکنز چھوٹے نظر آئیں گے",
"ai_tools_button": "اے آئی ٹولز",
"enable_ai_tools": "اے آئی ٹولز کے لیے شارٹ کٹس دکھائیں",
//"googleAppsMenuText": "Google Apps",
"googleAppsMenuInfo": "گوگل ایپس کے لیے شارٹ کٹس دکھائیں",
"todoListText": "To Do List",
"todoListInfo": "یومیہ ٹو ڈو لسٹ دکھائیں",

// Digital Clock
"digitalclocktitle": "ڈیجیٹل گھڑی",
"digitalclockinfo": "ڈیجیٹل گھڑی پر جائیں",
"timeformattitle": "12 گھنٹوں کی شکل",
"timeformatinfo": "12 گھنٹے کی شکل استعمال کریں",
"greetingtitle": "سلام",
"greetinginfo": "کسٹم ٹیکسٹ کے نیچے سلام دکھائیں",

// Misc
"userTextTitle": "حسب ضرورت ٹیکسٹ",
"userTextInfo": "گھڑی کے نیچے اپنا ٹیکسٹ دکھائیں",
"fahrenheitCelsiusCheckbox": "فارن ہائیٹ پر تبدیل کریں",
"fahrenheitCelsiusText": "تبدیلیوں کے لیے صفحہ ریفریش کریں",
"micIconTitle": "مائیکروفون آئیکن چھپائیں",
"micIconInfo": "اگر آواز سے ٹائپنگ کام نہیں کر رہی",
"hideSearchWith": "سرچ انجن چھپائیں",
"hideSearchWithInfo": "سرچ انجن تبدیل کرنے کے لیے آئیکن پر کلک کریں",
"search_suggestions_button": "سرچ تجاویز",
"search_suggestions_text": "سرچ تجاویز فعال کریں",

// Proxy
"useproxytitletext": "پراکسی بائی پاس",
"useproxyText": "اگر سرچ تجاویز کام نہیں کر رہیں",
"ProxyText": "CORS بائی پاس پراکسی",
"ProxySubtext": "اپنی CORS بائی پاس پراکسی شامل کریں",
"HostproxyButton": "اپنی پراکسی ہوسٹ کریں",
"saveproxy": "محفوظ کریں",

// Location
"UserLocText": "اپنا مقام درج کریں",
"UserLocSubtext": "اگر موسم کا مقام درست نہیں ہے",
"userLoc": "آپ کا شہر یا نقاط (عرض البلد، طول البلد)",
"saveLoc": "محفوظ کریں",

// Weather
"WeatherApiText": "اپنی WeatherAPI کلید درج کریں",
"WeatherApiSubtext": "اگر موسم کی فعالیت کام نہیں کر رہی",
"userAPI": "آپ کی weatherAPI کلید",
"LearnMoreButton": "مزید جانیں",
"saveAPI": "محفوظ کریں",

// Body Items
// Calendar
"days": ["اتوار", "پیر", "منگل", "بدھ", "جمعرات", "جمعہ", "ہفتہ"],
"months": ["جنوری", "فروری", "مارچ", "اپریل", "مئی", "جون", "جولائی", "اگست", "ستمبر", "اکتوبر", "نومبر", "دسمبر"],

// Weather
"humidityLevel": "نمی",
"feelsLike": "محسوس",
"location": "زمین",

// New Tab Item
"conditionText": "ہیلو! آج آپ کیسے ہیں؟",
"enterBtn": "تلاش کریں",
"searchPlaceholder": "یہاں لکھیں...",
"listenPlaceholder": "سن رہا ہے...",
"todoPlaceholder": "کام شامل کریں...",
"searchWithHint": "کے ساتھ تلاش کریں",
"ai_tools": "اے آئی ٹولز",
"userText": "ترمیم کے لیے یہاں کلک کریں",

// Greeting
"greeting": {
"morning": "صبح بخیر!",
"afternoon": "دوپہر بخیر!",
"evening": "شام بخیر!"
},

// Search Engines
"googleEngine": "گوگل",
"duckEngine": "ڈَک",
"bingEngine": "بِنگ",
"braveEngine": "بریو",
"youtubeEngine": "یوٹیوب",

// AI Tools
"chatGPT": "چیٹ جی پی ٹی",
"gemini": "جیمنائی",
"copilot": "کوپائلٹ",
"perplexity": "پرپلکسیٹی",
"firefly": "اڈوب فائر فلائی",
"metaAI": "میٹا اے آئی",

// Wallpaper and settings
"uploadWallpaperText": "وال پیپر اپلوڈ کریں",
"backupText": "بیک اپ",
"restoreText": "بحال کریں",
"rangColor": "رنگ چنیں",

// Dialog boxes (alerts)
"confirmWallpaper": "کیا آپ آج کے لیے ایک نئی تصویر کو وال پیپر کے طور پر سیٹ کرنا چاہتے ہیں؟",
"confirmRestore": "کیا آپ واقعی اپنی ترتیبات ری سیٹ کرنا چاہتے ہیں؟ یہ عمل واپس نہیں ہو سکے گا۔",
"Nobackgroundset": "اس وقت کوئی پس منظر تصویر سیٹ نہیں ہے۔",
"clearbackgroundimage": "کیا آپ واقعی پس منظر کی تصویر کو ہٹانا چاہتے ہیں؟",
"ProxyDisclaimer": "تمام پراکسی فیچرز ڈیفالٹ طور پر بند ہیں۔\n\nاگر آپ سرچ تجاویز اور CORS بائی پاس پراکسی کو فعال کرتے ہیں تو بہتر رازداری کے لیے اپنی پراکسی کو ہوسٹ کرنا سختی سے مشورہ دیا جاتا ہے۔\n\nڈیفالٹ طور پر پراکسی https://mynt-proxy.rhythmcorehq.com پر سیٹ ہوگی، اس کا مطلب ہے کہ آپ کا سارا ڈیٹا اس سروس کے ذریعے گزرے گا، جو رازداری کے مسائل پیدا کر سکتا ہے۔",
"failedbackup": "بیک اپ ناکام ہوگیا: ",
"restorecompleted": "بحالی کامیابی سے مکمل ہوگئی!",
"restorefailed": "بحالی ناکام ہوگئی: "
};
5 changes: 3 additions & 2 deletions manifest(firefox).json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "Material You NewTab",
"version": "3.0.33",
"version": "3.0.40",
"description": "A Simple New Tab (browser's home page) inspired by Google's 'Material You' design.",
"permissions": [
"bookmarks",
Expand All @@ -23,5 +23,6 @@
},
"chrome_url_overrides": {
"newtab": "index.html"
}
},
"incognito": "split"
}
5 changes: 3 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 3,
"name": "Material You NewTab",
"version": "3.0.33",
"version": "3.0.40",
"description": "A Simple New Tab (browser's home page) inspired by Google's 'Material You' design.",
"optional_permissions": ["bookmarks"],
"host_permissions": [
Expand All @@ -19,5 +19,6 @@
},
"chrome_url_overrides": {
"newtab": "index.html"
}
},
"incognito": "split"
}
2 changes: 2 additions & 0 deletions scripts/clock.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ function updateDate() {
az: `${dayName.substring(0, 3)}, ${dayOfMonth} ${monthName.substring(0, 3)}`,
sl: `${dayName}, ${dayOfMonth}. ${monthName.substring(0, 3)}.`,
hu: `${monthName.substring(0, 3)} ${dayOfMonth}, ${dayName}`, // Dec 22, Kedd
ur: `${dayName}، ${dayOfMonth} ${monthName}`,
default: `${dayName.substring(0, 3)}, ${monthName.substring(0, 3)} ${dayOfMonth}` // Sun, Dec 22
};
document.getElementById("date").innerText = dateDisplay[currentLanguage] || dateDisplay.default;
Expand Down Expand Up @@ -200,6 +201,7 @@ function updatedigiClock() {
idn: `${dayOfMonth} ${dayName}`,
fr: `${dayName} ${dayOfMonth}`, // Mardi 11
hu: `${dayName} ${dayOfMonth}`, // Kedd 11
ur: `${dayName}، ${dayOfMonth}`,
default: `${dayOfMonth} ${dayName.substring(0, 3)}`, // 24 Thu
};
const dateString = dateFormats[currentLanguage] || dateFormats.default;
Expand Down
27 changes: 27 additions & 0 deletions scripts/languages.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const translations = {
az: az, // Azerbaijani
sl: sl, // Slovenian
np: np, // Nepali
ur: ur, // Urdu
};

// Define the width of the menu container for each language
Expand Down Expand Up @@ -79,6 +80,9 @@ function localizeNumbers(text, language) {
return text; // Return the localized text
}

// Right-to-left languages
const rtlLanguages = ['ur'];

// Function to apply the language to the page
function applyLanguage(lang) {
// Mapping of text elements and their translation keys
Expand Down Expand Up @@ -257,15 +261,38 @@ function applyLanguage(lang) {
}
}

// Function to dynamically load Google Fonts
function loadFont(fontUrl) {
if (!document.querySelector(`link[href="${fontUrl}"]`)) {
const link = document.createElement("link");
link.rel = "stylesheet";
link.href = fontUrl;
document.head.appendChild(link);
}
}

// Dynamically update the font family based on the language
const root = document.documentElement;
const commonFontStack = "'poppins', 'Poppins', sans-serif";
if (lang === 'vi') {
loadFont("https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro&display=swap");
root.style.setProperty('--main-font-family', `'Be Vietnam Pro', ${commonFontStack}`);
} else if (lang === 'ur') {
loadFont("https://fonts.googleapis.com/css2?family=Noto+Sans+Arabic&display=swap");
root.style.setProperty('--main-font-family', `'Noto Sans Arabic', ${commonFontStack}`);
document.body.classList.add('lang-ur'); // Apply special styles
} else {
root.style.setProperty('--main-font-family', commonFontStack);
document.body.classList.remove('lang-ur');
}

// Apply the direction to the elements based on the language
const rtlElements = ['.menuBar', '#conditionText'];
rtlElements.forEach(selector => {
const element = document.querySelector(selector);
element.style.direction = rtlLanguages.includes(lang) ? 'rtl' : 'ltr';
});

// Save the selected language in localStorage
saveLanguageStatus('selectedLanguage', lang);
}
Expand Down
17 changes: 13 additions & 4 deletions scripts/weather.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,14 @@ async function getWeatherData() {
const localizedTempFahrenheit = localizeNumbers(tempFahrenheit.toString(), currentLanguage);
const localizedFeelsLikeFahrenheit = localizeNumbers(feelsLikeFahrenheit.toString(), currentLanguage);

// Check if language is RTL
const isRTL = rtlLanguages.includes(currentLanguage);

// Set humidity level
const humidityLabel = translations[currentLanguage]?.humidityLevel || translations["en"].humidityLevel; // Fallback to English if translation is missing
document.getElementById("humidityLevel").textContent = `${humidityLabel} ${localizedHumidity}%`;
const humidityLabel = translations[currentLanguage]?.humidityLevel || translations["en"].humidityLevel;
document.getElementById("humidityLevel").textContent = isRTL
? `${localizedHumidity}% ${humidityLabel}` // RTL: "76% ytidimuH"
: `${humidityLabel} ${localizedHumidity}%`;

// Event Listener for the Fahrenheit toggle
const fahrenheitCheckbox = document.getElementById("fahrenheitCheckbox");
Expand All @@ -259,7 +264,9 @@ async function getWeatherData() {

// Update feels like
const feelsLikeFUnit = langWithSpaceBeforeDegree.includes(currentLanguage) ? ' °F' : '°F';
feelsLikeElement.textContent = `${feelsLikeLabel} ${localizedFeelsLikeFahrenheit}${feelsLikeFUnit}`;
feelsLikeElement.textContent = isRTL
? `${localizedFeelsLikeFahrenheit}${feelsLikeFUnit} ${feelsLikeLabel}`
: `${feelsLikeLabel} ${localizedFeelsLikeFahrenheit}${feelsLikeFUnit}`;
} else {
// Update temperature
tempElement.textContent = localizedTempCelsius;
Expand All @@ -270,7 +277,9 @@ async function getWeatherData() {

// Update feels like
const feelsLikeCUnit = langWithSpaceBeforeDegree.includes(currentLanguage) ? ' °C' : '°C';
feelsLikeElement.textContent = `${feelsLikeLabel} ${localizedFeelsLikeCelsius}${feelsLikeCUnit}`;
feelsLikeElement.textContent = isRTL
? `${localizedFeelsLikeCelsius}${feelsLikeCUnit} ${feelsLikeLabel}`
: `${feelsLikeLabel} ${localizedFeelsLikeCelsius}${feelsLikeCUnit}`;
}
};
updateTemperatureDisplay();
Expand Down
Loading

0 comments on commit af0a2da

Please sign in to comment.