Skip to content

Commit

Permalink
feat: Update language configurations and adjust first day of the week
Browse files Browse the repository at this point in the history
- Standardized the data structure by ensuring a 'code' property for all language configurations.
- Adjusted the first day of the week (`dow`) based on cultural norms for certain languages.
- Enhanced error handling for unknown language codes in `codeLang` function.
  • Loading branch information
mctlisboa authored Sep 26, 2023
1 parent f4ff45f commit 35b0e18
Showing 1 changed file with 220 additions and 19 deletions.
239 changes: 220 additions & 19 deletions src/lang.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export const langs = [
{
code: 'pt',
week: {
dow: 1,
doy: 4,
Expand Down Expand Up @@ -103,27 +104,227 @@ export const langs = [
allDayText: 'Toute la journée',
moreLinkText: 'en plus',
noEventsText: 'Aucun évènement à afficher',
},
{
code: 'de',
week: {
dow: 1,
doy: 4,
},
buttonText: {
prev: 'Zurück',
next: 'Weiter',
today: 'Heute',
year: 'Jahr',
month: 'Monat',
week: 'Woche',
day: 'Tag',
list: 'Terminübersicht',
},
weekText: 'Woch.',
allDayText: 'Ganzer Tag',
moreLinkText: 'mehr',
noEventsText: 'Keine Ereignisse anzuzeigen',
},
{
code: 'it',
week: {
dow: 1,
doy: 4,
},
buttonText: {
prev: 'Precedente',
next: 'Successivo',
today: 'Oggi',
year: 'Anno',
month: 'Mese',
week: 'Settimana',
day: 'Giorno',
list: 'Agenda',
},
weekText: 'Sett.',
allDayText: 'Tutto il giorno',
moreLinkText: 'altro',
noEventsText: 'Non ci sono eventi da mostrare',
},
{
code: 'nl',
week: {
dow: 1,
doy: 4,
},
buttonText: {
prev: 'Vorige',
next: 'Volgende',
today: 'Vandaag',
year: 'Jaar',
month: 'Maand',
week: 'Week',
day: 'Dag',
list: 'Agenda',
},
weekText: 'Week',
allDayText: 'Hele dag',
moreLinkText: 'meer',
noEventsText: 'Geen evenementen om te tonen',
},
{
code: 'zh-CN',
week: {
dow: 1,
doy: 4,
},
buttonText: {
prev: '上一步',
next: '下一步',
today: '今天',
year: '年',
month: '月',
week: '周',
day: '日',
list: '日程',
},
weekText: '周',
allDayText: '整天',
moreLinkText: '更多',
noEventsText: '没有要显示的事件',
},
{
code: 'ar',
week: {
dow: 6,
doy: 4,
},
buttonText: {
prev: 'السابق',
next: 'التالي',
today: 'اليوم',
year: 'السنة',
month: 'الشهر',
week: 'الأسبوع',
day: 'اليوم',
list: 'جدول',
},
weekText: 'أسبوع',
allDayText: 'طوال اليوم',
moreLinkText: 'المزيد',
noEventsText: 'لا يوجد أحداث لعرضها',
},
{
code: 'ja',
week: {
dow: 1,
doy: 4,
},
buttonText: {
prev: '前',
next: '次',
today: '今日',
year: '年',
month: '月',
week: '週',
day: '日',
list: '予定',
},
weekText: '週',
allDayText: '終日',
moreLinkText: '他',
noEventsText: '表示するイベントはありません',
},
{
code: 'ko',
week: {
dow: 0,
doy: 4,
},
buttonText: {
prev: '이전',
next: '다음',
today: '오늘',
year: '년',
month: '월',
week: '주',
day: '일',
list: '일정',
},
weekText: '주',
allDayText: '종일',
moreLinkText: '더 보기',
noEventsText: '표시할 이벤트가 없습니다',
},
{
code: 'sv',
week: {
dow: 1,
doy: 4,
},
buttonText: {
prev: 'Föregående',
next: 'Nästa',
today: 'Idag',
year: 'År',
month: 'Månad',
week: 'Vecka',
day: 'Dag',
list: 'Schema',
},
weekText: 'V.',
allDayText: 'Hela dagen',
moreLinkText: 'mer',
noEventsText: 'Inga händelser att visa',
},
{
code: 'no',
week: {
dow: 1,
doy: 4,
},
buttonText: {
prev: 'Forrige',
next: 'Neste',
today: 'I dag',
year: 'År',
month: 'Måned',
week: 'Uke',
day: 'Dag',
list: 'Agenda',
},
weekText: 'Uke',
allDayText: 'Hele dagen',
moreLinkText: 'mer',
noEventsText: 'Ingen hendelser å vise',
},
{
code: 'hi',
week: {
dow: 1,
doy: 4,
},
buttonText: {
prev: 'पिछला',
next: 'अगला',
today: 'आज',
year: 'वर्ष',
month: 'माह',
week: 'सप्ताह',
day: 'दिन',
list: 'कार्यक्रम',
},
weekText: 'सप्ताह',
allDayText: 'पूरा दिन',
moreLinkText: 'और देखें',
noEventsText: 'प्रदर्शित करने के लिए कोई घटना नहीं है',
}
]

export function codeLang(lang){
let code
export function codeLang(lang) {
const code = langs.findIndex(item => item.code === lang);

switch(lang){
case "pt":
code = 0
break;
case "es":
code = 1
break;
case "ru":
code = 2
break;
case "fa":
code = 3
break;
}
if (code === -1) {
console.warn(`Unknown language code: ${lang}`);
return null;
}

console.log(code, 'code', lang)
return code
}
console.log(code, 'code', lang);
return code;
}

0 comments on commit 35b0e18

Please sign in to comment.