-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
326 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
dist/ | ||
.wrangler/ | ||
# Autogenerated by esbuild. | ||
workers-site/index.js | ||
node_modules/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{ | ||
"en": { | ||
"placePagePrompt": "Organic Maps app is free for everyone, thanks to your donations. No ads. No trackers. Open source.", | ||
"perMonth": "/month", | ||
"perYear": "/year", | ||
"otherAmount": "Other" | ||
}, | ||
"de": { | ||
"placePagePrompt": "Organic Maps ist dank deiner Spenden für alle kostenlos. Keine Werbung. Keine Tracker. Open Source.", | ||
"perMonth": "/Monat", | ||
"perYear": "/Jahr", | ||
"otherAmount": "Andere" | ||
}, | ||
"fr": { | ||
"placePagePrompt": "L'application Organic Maps est gratuite pour tout le monde grâce à vos dons. Pas de publicité. Pas de trackers. Open-source.", | ||
"perMonth": "/mois", | ||
"perYear": "/an", | ||
"otherAmount": "Autre" | ||
}, | ||
"nl": { | ||
"placePagePrompt": "De Organic Maps app is gratis voor iedereen dankzij jullie donaties. Geen advertenties. Geen trackers. Open-source.", | ||
"perMonth": "/maand", | ||
"perYear": "/jaar", | ||
"otherAmount": "Ander" | ||
}, | ||
"it": { | ||
"placePagePrompt": "L'app Organic Maps è gratuita per tutti grazie alle vostre donazioni. Nessuna pubblicità. Nessun tracker. Open-source.", | ||
"perMonth": "/mese", | ||
"perYear": "/anno", | ||
"otherAmount": "Altro" | ||
}, | ||
"es": { | ||
"placePagePrompt": "Organic Maps es gratis para todos gracias a sus donaciones. Sin anuncios. Sin rastreadores. Código abierto.", | ||
"perMonth": "/mes", | ||
"perYear": "/año", | ||
"otherAmount": "Otro" | ||
}, | ||
"pt": { | ||
"placePagePrompt": "O app Organic Maps é gratuito para todos graças às suas doações. Sem anúncios. Sem rastreadores. Código aberto.", | ||
"perMonth": "/mês", | ||
"perYear": "/ano", | ||
"otherAmount": "Outro" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import LOCALES_JSON from './locales.json'; | ||
|
||
export interface Locale { | ||
placePagePrompt: string; | ||
perMonth: string; | ||
perYear: string; | ||
otherAmount: string; | ||
} | ||
|
||
export interface Locales { | ||
[key: string]: Locale; | ||
} | ||
|
||
const LOCALES = LOCALES_JSON as Locales; | ||
export default LOCALES; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,198 @@ | ||
{ | ||
"FR": [ | ||
{ | ||
"title": "4,99€$per_month", | ||
"link": "https://donate.stripe.com/6oEg2912f2c81r200j" | ||
}, | ||
{ | ||
"title": "34,99€$per_year", | ||
"link": "https://donate.stripe.com/eVa2bjdP19EA0mY6oI" | ||
}, | ||
{ | ||
"title": "$other", | ||
"link": "https://donate.stripe.com/28odU16mzg2Yc5GfYY" | ||
} | ||
], | ||
"DE": [ | ||
{ | ||
"title": "4,99€$per_month", | ||
"link": "https://donate.stripe.com/6oEg2912f2c81r200j" | ||
}, | ||
{ | ||
"title": "34,99€$per_year", | ||
"link": "https://donate.stripe.com/eVa2bjdP19EA0mY6oI" | ||
}, | ||
{ | ||
"title": "$other", | ||
"link": "https://donate.stripe.com/28odU16mzg2Yc5GfYY" | ||
} | ||
], | ||
"NL": [ | ||
{ | ||
"title": "4,99€$per_month", | ||
"link": "https://donate.stripe.com/6oEg2912f2c81r200j" | ||
}, | ||
{ | ||
"title": "34,99€$per_year", | ||
"link": "https://donate.stripe.com/eVa2bjdP19EA0mY6oI" | ||
}, | ||
{ | ||
"title": "$other", | ||
"link": "https://donate.stripe.com/28odU16mzg2Yc5GfYY" | ||
} | ||
], | ||
"IT": [ | ||
{ | ||
"title": "4,99€$per_month", | ||
"link": "https://donate.stripe.com/6oEg2912f2c81r200j" | ||
}, | ||
{ | ||
"title": "34,99€$per_year", | ||
"link": "https://donate.stripe.com/eVa2bjdP19EA0mY6oI" | ||
}, | ||
{ | ||
"title": "$other", | ||
"link": "https://donate.stripe.com/28odU16mzg2Yc5GfYY" | ||
} | ||
], | ||
"ES": [ | ||
{ | ||
"title": "4,99€$per_month", | ||
"link": "https://donate.stripe.com/6oEg2912f2c81r200j" | ||
}, | ||
{ | ||
"title": "34,99€$per_year", | ||
"link": "https://donate.stripe.com/eVa2bjdP19EA0mY6oI" | ||
}, | ||
{ | ||
"title": "$other", | ||
"link": "https://donate.stripe.com/28odU16mzg2Yc5GfYY" | ||
} | ||
], | ||
"PT": [ | ||
{ | ||
"title": "4,99€$per_month", | ||
"link": "https://donate.stripe.com/6oEg2912f2c81r200j" | ||
}, | ||
{ | ||
"title": "34,99€$per_year", | ||
"link": "https://donate.stripe.com/eVa2bjdP19EA0mY6oI" | ||
}, | ||
{ | ||
"title": "$other", | ||
"link": "https://donate.stripe.com/28odU16mzg2Yc5GfYY" | ||
} | ||
], | ||
"BE": [ | ||
{ | ||
"title": "4,99€$per_month", | ||
"link": "https://donate.stripe.com/6oEg2912f2c81r200j" | ||
}, | ||
{ | ||
"title": "34,99€$per_year", | ||
"link": "https://donate.stripe.com/eVa2bjdP19EA0mY6oI" | ||
}, | ||
{ | ||
"title": "$other", | ||
"link": "https://donate.stripe.com/28odU16mzg2Yc5GfYY" | ||
} | ||
], | ||
"AT": [ | ||
{ | ||
"title": "4,99€$per_month", | ||
"link": "https://donate.stripe.com/6oEg2912f2c81r200j" | ||
}, | ||
{ | ||
"title": "34,99€$per_year", | ||
"link": "https://donate.stripe.com/eVa2bjdP19EA0mY6oI" | ||
}, | ||
{ | ||
"title": "$other", | ||
"link": "https://donate.stripe.com/28odU16mzg2Yc5GfYY" | ||
} | ||
], | ||
"LU": [ | ||
{ | ||
"title": "4,99€$per_month", | ||
"link": "https://donate.stripe.com/6oEg2912f2c81r200j" | ||
}, | ||
{ | ||
"title": "34,99€$per_year", | ||
"link": "https://donate.stripe.com/eVa2bjdP19EA0mY6oI" | ||
}, | ||
{ | ||
"title": "$other", | ||
"link": "https://donate.stripe.com/28odU16mzg2Yc5GfYY" | ||
} | ||
], | ||
"MC": [ | ||
{ | ||
"title": "4,99€$per_month", | ||
"link": "https://donate.stripe.com/6oEg2912f2c81r200j" | ||
}, | ||
{ | ||
"title": "34,99€$per_year", | ||
"link": "https://donate.stripe.com/eVa2bjdP19EA0mY6oI" | ||
}, | ||
{ | ||
"title": "$other", | ||
"link": "https://donate.stripe.com/28odU16mzg2Yc5GfYY" | ||
} | ||
], | ||
"AD": [ | ||
{ | ||
"title": "4,99€$per_month", | ||
"link": "https://donate.stripe.com/6oEg2912f2c81r200j" | ||
}, | ||
{ | ||
"title": "34,99€$per_year", | ||
"link": "https://donate.stripe.com/eVa2bjdP19EA0mY6oI" | ||
}, | ||
{ | ||
"title": "$other", | ||
"link": "https://donate.stripe.com/28odU16mzg2Yc5GfYY" | ||
} | ||
], | ||
"SM": [ | ||
{ | ||
"title": "4,99€$per_month", | ||
"link": "https://donate.stripe.com/6oEg2912f2c81r200j" | ||
}, | ||
{ | ||
"title": "34,99€$per_year", | ||
"link": "https://donate.stripe.com/eVa2bjdP19EA0mY6oI" | ||
}, | ||
{ | ||
"title": "$other", | ||
"link": "https://donate.stripe.com/28odU16mzg2Yc5GfYY" | ||
} | ||
], | ||
"GB": [ | ||
{ | ||
"title": "£4.99$per_month", | ||
"link": "https://donate.stripe.com/8wMg29fX98Awd9K28u" | ||
}, | ||
{ | ||
"title": "£34.99$per_year", | ||
"link": "https://donate.stripe.com/eVabLT9yL2c89Xy7sP" | ||
}, | ||
{ | ||
"title": "$other", | ||
"link": "https://donate.stripe.com/6oE7vD26j3gc2v69AC" | ||
} | ||
], | ||
"US": [ | ||
{ | ||
"title": "$5.49$per_month", | ||
"link": "https://donate.stripe.com/00g3fncKXcQMedO5kL" | ||
}, | ||
{ | ||
"title": "$36.99$per_year", | ||
"link": "https://donate.stripe.com/bIY6rz5ivcQM9XyaF6" | ||
}, | ||
{ | ||
"title": "$other", | ||
"link": "https://donate.stripe.com/7sIcPX5ivg2Y2v6145" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import LOCALES from './locales'; | ||
import PRODUCTS_JSON from './products.json'; | ||
|
||
export interface Product { | ||
title: string; | ||
link: string; | ||
} | ||
|
||
const PRODUCTS = PRODUCTS_JSON as Record<string, Product[]>; | ||
|
||
export interface ProductsConfig { | ||
placePagePrompt: string; | ||
products: Product[]; | ||
} | ||
|
||
export function getProducts(locale: string | null): ProductsConfig | undefined { | ||
if (!locale) { | ||
return undefined; | ||
} | ||
const parts = locale.split(/[-_]/); | ||
const language = parts[0].toLowerCase(); | ||
const country = parts[1] ? parts[1].toUpperCase() : ''; | ||
|
||
const products = PRODUCTS[country]; | ||
const trans = LOCALES[language]; | ||
if (products === undefined || trans === undefined) { | ||
return undefined; | ||
} | ||
|
||
return { | ||
placePagePrompt: trans.placePagePrompt, | ||
products: products.map((product) => ({ | ||
...product, | ||
title: product.title | ||
.replace('$other', trans.otherAmount) | ||
.replace('$per_month', trans.perMonth) | ||
.replace('$per_year', trans.perYear), | ||
})), | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { describe, expect, test } from '@jest/globals'; | ||
import { getProducts } from '../src/products'; | ||
|
||
describe('getProducts', () => { | ||
test('fr-FR', () => { | ||
const fr_FR = getProducts('fr-FR'); | ||
expect(fr_FR).toBeDefined(); | ||
if (!fr_FR) return; | ||
expect(fr_FR.placePagePrompt).toBe( | ||
"L'application Organic Maps est gratuite pour tout le monde grâce à vos dons. Pas de publicité. Pas de trackers. Open-source.", | ||
); | ||
expect(fr_FR.products[fr_FR.products.length - 1].title).toEqual('Autre'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters