-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add PlacePage donations #88
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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() : ''; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Почему страну нельзя брать из заголовков CF, как сейчас берётся континент? |
||
|
||
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Какая вероятность возмущённых комментов по поводу сбора дополнительной инфы о юзерах при добавлении отправки ещё одного хидера на сервер в открытых PR в основной репо? Можно ли без этого обойтись, чтобы не привлекать ненужное внимание к уже отправляющимся хидерам?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@biodranik если не слать локаль, то придется каждому юзеру качать всю эту инфу в полном объеме для всех языков (все переводы и все продукты) и фильтровать ее уже на этапе парсинга данных на устройстве. Если там будет много стран, то json будет приличный... да и не зачем на девайс приходить тому что не нужно...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (cf.country == 'France')
. Чем явная передача с клиента лучше?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$ 20
для кнопки, оно и отображается, а на сервер улетает что-то вродеhttps://url/buttonclicked?value=$%2020
.