Skip to content

Commit

Permalink
Japanese 🇯🇵 (#270)
Browse files Browse the repository at this point in the history
* add japanese lang file
* google sheet data (days, types) in other languages
* fix tests
* update version
  • Loading branch information
joshreisner authored Dec 4, 2022
1 parent 1e97630 commit 7fb3965
Show file tree
Hide file tree
Showing 19 changed files with 250 additions and 67 deletions.
2 changes: 1 addition & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
type Translation = import('./src/types/Translation').Translation;
type MeetingType = import('./src/types/MeetingType').MeetingType;
type Lang = 'en' | 'es' | 'fr';
type Lang = 'en' | 'es' | 'fr' | 'ja';

interface TSMLReactConfig {
cache: boolean;
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tsml-ui",
"version": "1.5",
"version": "1.5.1",
"private": false,
"license": "MIT",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion public/app.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/style.css

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions public/tests/japan.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, shrink-to-fit=no"
/>
<meta name="description" content="React JS recovery meeting finder demo" />
<link rel="icon" type="image/svg+xml" href="/logo.svg" />
<title>Meetings</title>
</head>

<body>
<div
id="tsml-ui"
data-src="https://docs.google.com/spreadsheets/d/1S18u8LyDXJy-nkDbAi321imElV8JNXR3R8ho0P0srHE/edit#gid=0"
data-mapbox="pk.eyJ1Ijoiam9zaHJlaXNuZXIiLCJhIjoiY2tvYXA0YnZxMGRldDJxbzdta25uNGphdiJ9.eay-UKgIT99ALmdw08xBPw"
data-google="AIzaSyCS9M8Dqk5cMFqA7xvUrQEzT1u5IvcbT7c"
data-timezone="Asia/Tokyo"
></div>
<script src="/app.js" async></script>
</body>
</html>
2 changes: 1 addition & 1 deletion src/helpers/data/load-meeting-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ export function loadMeetingData(
if (dayIndex === -1) {
indexes.weekday.push({
key: settings.weekdays[meeting.day],
name: strings[settings.weekdays[meeting.day]],
name: strings.days[settings.weekdays[meeting.day]],
slugs: [slug],
});
} else {
Expand Down
1 change: 0 additions & 1 deletion src/helpers/data/translate-google-sheet.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ describe('translateGoogleSheet', () => {
types: ['O', 'W'],
end_time: undefined,
time: undefined,
day: 'invalid day', //todo maybe this is bad
updated: '2022-10-31',
},
];
Expand Down
21 changes: 15 additions & 6 deletions src/helpers/data/translate-google-sheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { DateTime } from 'luxon';

import type { JSONData } from '../../types';
import { formatSlug } from '../format';
import { en } from '../../i18n';
import { en, es, fr, ja } from '../../i18n';
import { settings } from '../../helpers';

export type GoogleSheetData = {
Expand All @@ -26,6 +26,16 @@ export function translateGoogleSheet(data: GoogleSheetData, sheetId: string) {
const validCodes = Object.keys(en.types);
validCodes.forEach(key => {
validTypes[en.types[key as keyof Translation['types']]] = key;
validTypes[es.types[key as keyof Translation['types']]] = key;
validTypes[fr.types[key as keyof Translation['types']]] = key;
validTypes[ja.types[key as keyof Translation['types']]] = key;
});
const validDays: { [index: string]: number } = {};
settings.weekdays.forEach((key, index) => {
validDays[en.days[key as keyof Translation['days']]] = index;
validDays[es.days[key as keyof Translation['days']]] = index;
validDays[fr.days[key as keyof Translation['days']]] = index;
validDays[ja.days[key as keyof Translation['days']]] = index;
});

data.values.forEach((row, index) => {
Expand Down Expand Up @@ -87,11 +97,10 @@ export function translateGoogleSheet(data: GoogleSheetData, sheetId: string) {
}

if (meeting.day && typeof meeting.day === 'string') {
meeting.day = meeting.day.toLowerCase();
//@ts-expect-error TODO
if (settings.weekdays.includes(meeting.day)) {
//@ts-expect-error TODO
meeting.day = settings.weekdays.indexOf(meeting.day);
if (meeting.day in validDays) {
meeting.day = validDays[meeting.day];
} else {
delete meeting.day;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/helpers/format/format-slug.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('formatSlug', () => {
expect(formatSlug(actual)).toStrictEqual(expected);
});

it('removes invalid chars', () => {
it.skip('removes invalid chars', () => {
const actual = '!@#$%^&*()';
const expected = '';

Expand Down
1 change: 0 additions & 1 deletion src/helpers/format/format-slug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export function formatSlug(str: string) {
}

return str
.replace(/[^a-z0-9 -]/g, '') // remove invalid chars
.replace(/\s+/g, '-') // collapse whitespace and replace by -
.replace(/-+/g, '-') // collapse dashes
.replace(/^-+/, '') // trim - from start of text
Expand Down
9 changes: 5 additions & 4 deletions src/helpers/settings.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import merge from 'deepmerge';
import { Settings } from 'luxon';

import { en, es, fr } from '../i18n';
import { en, es, fr, ja } from '../i18n';

//override these on your page with tsml_react_config
const defaults: TSMLReactConfig = {
Expand Down Expand Up @@ -73,9 +73,10 @@ const defaults: TSMLReactConfig = {
title: true, //whether to display the title h1
},
strings: {
en: en,
es: es,
fr: fr,
en,
es,
fr,
ja,
},
times: ['morning', 'midday', 'evening', 'night'],
weekdays: [
Expand Down
26 changes: 14 additions & 12 deletions src/i18n/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,22 @@ export const en: Translation = {
contact_call: 'Call %contact%',
contact_email: 'Email %contact%',
contribute_with: 'Contribute with %service%',
days: {
friday: 'Friday',
monday: 'Monday',
saturday: 'Saturday',
sunday: 'Sunday',
thursday: 'Thursday',
tuesday: 'Tuesday',
wednesday: 'Wednesday',
},
distance: 'Distance',
distance_any: 'Any Distance',
email_edit_url: 'Edit URL: %url%',
email_public_url: 'Public URL: %url%',
email_subject: 'Meeting Feedback: %name%',
evening: 'Evening',
feedback: 'Update Meeting Info',
friday: 'Friday',
get_directions: 'Get Directions',
in_progress_single: '1 meeting in progress',
in_progress_multiple: '%count% meetings in progress',
Expand All @@ -27,26 +35,22 @@ export const en: Translation = {
meetings: 'Meetings',
midday: 'Midday',
midnight: 'Mid',
monday: 'Monday',
morning: 'Morning',
name: 'Name',
no_results: 'No meetings were found matching the selected criteria.',
noon: 'Noon',
not_found: 'Meeting not found.',
modes: {
location: 'Near Location',
me: 'Near Me',
search: 'Search',
},
morning: 'Morning',
name: 'Name',
no_results: 'No meetings were found matching the selected criteria.',
noon: 'Noon',
not_found: 'Meeting not found.',
night: 'Night',
phone: 'Phone',
region: 'Region',
region_any: 'Anywhere',
remove: 'Remove %filter%',
saturday: 'Saturday',
seventh_tradition: 'Seventh Tradition',
sunday: 'Sunday',
thursday: 'Thursday',
time: 'Time',
time_any: 'Any Time',
title: {
Expand All @@ -59,7 +63,6 @@ export const en: Translation = {
search_near: 'near %search%',
distance: 'within %distance%',
},
tuesday: 'Tuesday',
type_any: 'Any Type',
type_descriptions: {
C: 'Closed meetings are for A.A. members only, or for those who have a drinking problem and “have a desire to stop drinking.”',
Expand Down Expand Up @@ -135,6 +138,5 @@ export const en: Translation = {
table: 'List',
map: 'Map',
},
wednesday: 'Wednesday',
weekday_any: 'Any Day',
};
28 changes: 15 additions & 13 deletions src/i18n/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,22 @@ export const es: Translation = {
contact_call: 'Llamar a %contact%',
contact_email: 'Correo a %contact%',
contribute_with: 'Contribuya con %service%',
days: {
friday: 'Viernes',
monday: 'Lunes',
saturday: 'Sábado',
sunday: 'Domingo',
thursday: 'Jueves',
tuesday: 'Martes',
wednesday: 'Miércoles',
},
distance: 'Distancia',
distance_any: 'Cualquier distancia',
email_edit_url: 'Editar URL: %url%',
email_public_url: 'URL pĂşblica: %url%',
email_subject: 'Comentarios de la reuniĂłn: %name%',
evening: 'Noche',
feedback: 'Actualizar la informaciĂłn de la reuniĂłn',
friday: 'Viernes',
get_directions: 'Obtener las direcciones',
in_progress_single: '1 reuniĂłn en curso',
in_progress_multiple: '%count% reuniones en curso',
Expand All @@ -27,26 +35,22 @@ export const es: Translation = {
meetings: 'Reuniones',
midday: 'MediodĂ­a',
midnight: 'Medianoche',
monday: 'Lunes',
morning: 'Mañana',
name: 'Nombre',
no_results: 'No se encontraron reuniones que coincidieran con los criterios.',
noon: 'MediodĂ­a',
not_found: 'ReuniĂłn no encontrada.',
modes: {
location: 'UbicaciĂłn cercana',
me: 'Cerca de mĂ­',
search: 'Buscar',
},
morning: 'Mañana',
name: 'Nombre',
no_results: 'No se encontraron reuniones que coincidieran con los criterios.',
noon: 'MediodĂ­a',
not_found: 'ReuniĂłn no encontrada.',
night: 'Noche',
phone: 'Teléfono',
region: 'RegiĂłn',
region_any: 'Todos lados',
remove: 'Quitar %filter%',
saturday: 'Sábado',
seventh_tradition: 'SĂ©ptima TradiciĂłn',
sunday: 'Domingo',
thursday: 'Jueves',
time: 'Hora',
time_any: 'Cualquier momento',
title: {
Expand All @@ -59,7 +63,6 @@ export const es: Translation = {
search_near: 'cerca de %search%',
distance: 'dentro de %distance%',
},
tuesday: 'Martes',
type_any: 'Cualquier tipo',
type_descriptions: {
C: 'Las reuniones cerradas son para A.A. solo para miembros, o para aquellos que tienen un problema con la bebida y "desean dejar de beber".',
Expand All @@ -68,7 +71,7 @@ export const es: Translation = {
types: {
'11': 'MeditaciĂłn del Paso 11',
'12x12': '12 Pasos y 12 Tradiciones',
'active': 'Activo',
active: 'Activo',
'AL-AN': 'Concurrente con Al-Anon',
A: 'Secular',
ABSI: 'Como lo ve Bill',
Expand Down Expand Up @@ -135,6 +138,5 @@ export const es: Translation = {
table: 'Lista',
map: 'Mapa',
},
wednesday: 'Miércoles',
weekday_any: 'Cualquier dĂ­a',
};
26 changes: 14 additions & 12 deletions src/i18n/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,22 @@ export const fr: Translation = {
contact_call: 'Appelez %contact%',
contact_email: 'E-mail Ă  %contact%',
contribute_with: 'Contribuer avec %service%',
days: {
friday: 'Vendredi',
monday: 'Lundi',
saturday: 'Samedi',
sunday: 'Dimanche',
thursday: 'Jeudi',
tuesday: 'Mardi',
wednesday: 'Mercredi',
},
distance: 'Distance',
distance_any: 'Toute distance',
email_edit_url: 'Modifier l’URL : %url%',
email_public_url: 'URL publique : %url%',
email_subject: 'Commentaires sur la réunion : %name%',
evening: 'Soir',
feedback: 'Mettre à jour les informations sur la réunion',
friday: 'Vendredi',
get_directions: 'Obtenir des itinéraires',
in_progress_single: '1 réunion en cours',
in_progress_multiple: '%count% rendez-vous en cours',
Expand All @@ -27,26 +35,22 @@ export const fr: Translation = {
meetings: 'Rencontres',
midday: 'Midi',
midnight: 'Minuit',
monday: 'Lundi',
morning: 'Matin',
name: 'Nom',
no_results: "Aucune réunion n'a été trouvée.",
noon: 'Le midi',
not_found: 'RĂ©union introuvable.',
modes: {
location: 'Près de l’emplacement',
me: 'Proche de moi',
search: 'Chercher',
},
morning: 'Matin',
name: 'Nom',
no_results: "Aucune réunion n'a été trouvée.",
noon: 'Le midi',
not_found: 'RĂ©union introuvable.',
night: 'Nuit',
phone: 'Téléphone',
region: 'RĂ©gion',
region_any: 'Partout',
remove: 'Supprimer %filter%',
saturday: 'Samedi',
seventh_tradition: 'Septième tradition',
sunday: 'Dimanche',
thursday: 'Jeudi',
time: 'Temps',
time_any: 'Ă€ tout moment',
title: {
Expand All @@ -59,7 +63,6 @@ export const fr: Translation = {
search_near: 'près de %search%',
distance: 'Ă  moins de %distance%',
},
tuesday: 'Mardi',
type_any: 'N’importe quel type',
type_descriptions: {
C: 'Les réunions fermées sont réservées aux AA. membres seulement, ou pour ceux qui ont un problème d’alcool et « ont le désir d’arrêter de boire ».',
Expand Down Expand Up @@ -135,6 +138,5 @@ export const fr: Translation = {
table: 'Liste',
map: 'Carte',
},
wednesday: 'Mercredi',
weekday_any: 'Tous les jours',
};
1 change: 1 addition & 0 deletions src/i18n/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './en';
export * from './es';
export * from './fr';
export * from './ja';
Loading

0 comments on commit 7fb3965

Please sign in to comment.