mirror of
https://github.com/mempool/mempool.git
synced 2025-01-01 03:04:27 +01:00
4658b47007
This PR adds basic i18n support into the mempool frontend, together with a smooth workflow for developers and translators to collaborate: * Using the existing @angular/localize module, developers add i18n metadata to any frontend strings their new features or changes modify * Using the new npm script `i18n-extract-from-source`, developers extract the i18n data from source code into `src/locale/messages.xlf` * After pushing the updated `src/locale/messages.xlf` to GitHub, the Transifex service will update its database from the new source data * Using the Transifex website UI, translators can work together to translate all the mempool frontend strings into their native languages * Using the new npm script `i18n-pull-from-transifex`, developers can pull in completed translations from Transifex, and commit them into git. This flow requires an API key from Transifex, which can be obtained at https://www.transifex.com/user/settings/api/ to be used with the python script installed by `pip install transifex-client` - after preparing these, run the npm script which will ask you for the API key the first time. When downloading is complete, you can test building the frontend, and if successful, commit the new strings files into git. This PR implements a new locale selector in the footer of the homepage dashboard, and includes WIP translations for the following languages: * Czech (cs) * German (de) * Japanese (ja) * Norwegian (nn) * Spanish (es) * Swedish (sv) * Ukrainian (uk) * Persian (fa) * Portugese (pt) * Turkish (tr) * Dutch (nl) * French (fr) * Chinese (zh) * Slovenian (sl) * Korean (ko) * Polish (pl) The user-agent's `Accept-Language` header is used to automatically detect their preferred language, which can be manually overriden by the pull-down selector, which saves their preference to a cookie, which is used by nginx to serve the correct HTML bundle to the user. Remaining tasks include adding i18n metadata for strings in the Bisq and Liquid frontend code, mouseover hover tooltip strings, hard-coded og metadata inside HTML templates, and many other places. This will be done in a separate PR. When upgrading to add i18n support, mempool instance operators must take care to install the new nginx.conf and nginx-mempool.conf files, and tweak for their specific site configuration. Fixes #81
196 lines
5.9 KiB
Plaintext
196 lines
5.9 KiB
Plaintext
root /mempool/public_html/mainnet/;
|
|
|
|
index index.html;
|
|
|
|
add_header Onion-Location http://mempoolhqx4isw62xs7abwphsq7ldayuidyx2v2oethdhhj6mlo2r6ad.onion$request_uri;
|
|
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload";
|
|
|
|
set $frameOptions "DENY";
|
|
set $contentSecurityPolicy "frame-ancestors 'none'";
|
|
if ($http_referer ~ ^https://mempool.space/)
|
|
{
|
|
set $frameOptions "ALLOW-FROM https://mempool.space";
|
|
set $contentSecurityPolicy "frame-ancestors https://mempool.space";
|
|
}
|
|
if ($http_referer ~ ^https://mempool.ninja/)
|
|
{
|
|
set $frameOptions "ALLOW-FROM https://mempool.ninja";
|
|
set $contentSecurityPolicy "frame-ancestors https://mempool.ninja";
|
|
}
|
|
if ($http_referer ~ ^https://node100.bitcoin.wiz.biz/)
|
|
{
|
|
set $frameOptions "ALLOW-FROM https://node100.bitcoin.wiz.biz";
|
|
set $contentSecurityPolicy "frame-ancestors https://node100.bitcoin.wiz.biz";
|
|
}
|
|
if ($http_referer ~ ^https://wiz.biz/)
|
|
{
|
|
set $frameOptions "ALLOW-FROM https://wiz.biz";
|
|
set $contentSecurityPolicy "frame-ancestors https://wiz.biz";
|
|
}
|
|
|
|
add_header X-Frame-Options $frameOptions;
|
|
add_header Content-Security-Policy $contentSecurityPolicy;
|
|
|
|
# fallback
|
|
location / {
|
|
#return 302 https://mempool.space/$request_uri;
|
|
try_files /$lang/$uri /$lang/$uri/ $uri $uri/ /en-US/$uri /$lang/index.html /en-US/index.html =404;
|
|
}
|
|
|
|
# location block using regex are matched in order
|
|
|
|
# used to rewrite resources from /<lang>/ to /en-US/
|
|
location ~ ^/(ar|bg|bs|ca|cs|da|de|et|el|es|eo|eu|fa|fr|gl|ko|hr|id|it|he|ka|lv|lt|hu|mk|ms|nl|ja|no|nb|nn|pl|pt|pt-BR|ro|ru|sk|sl|sr|sh|fi|sv|th|tr|uk|vi|zh)/resources/ {
|
|
rewrite ^/[a-zA-Z-]*/resources/(.*) /en-US/resources/$1;
|
|
}
|
|
# used for cookie override
|
|
location ~ ^/(ar|bg|bs|ca|cs|da|de|et|el|es|eo|eu|fa|fr|gl|ko|hr|id|it|he|ka|lv|lt|hu|mk|ms|nl|ja|no|nb|nn|pl|pt|pt-BR|ro|ru|sk|sl|sr|sh|fi|sv|th|tr|uk|vi|zh)/ {
|
|
try_files $uri $uri/ /$1/index.html =404;
|
|
}
|
|
|
|
# add /sitemap for production SEO
|
|
location /sitemap {
|
|
try_files $uri =410;
|
|
}
|
|
# old /explorer redirect from v1 days
|
|
location /explorer {
|
|
rewrite /explorer/(.*) https://$host/$1 permanent;
|
|
}
|
|
|
|
# static API docs
|
|
location = /api {
|
|
#return 302 https://mempool.space/$request_uri;
|
|
try_files $uri $uri/ /en-US/index.html =404;
|
|
}
|
|
location = /api/ {
|
|
#return 302 https://mempool.space/$request_uri;
|
|
try_files $uri $uri/ /en-US/index.html =404;
|
|
}
|
|
location = /liquid/api {
|
|
#return 302 https://mempool.space/$request_uri;
|
|
try_files $uri $uri/ /en-US/index.html =404;
|
|
}
|
|
location = /liquid/api/ {
|
|
#return 302 https://mempool.space/$request_uri;
|
|
try_files $uri $uri/ /en-US/index.html =404;
|
|
}
|
|
location = /testnet/api {
|
|
#return 302 https://mempool.space/$request_uri;
|
|
try_files $uri $uri/ /en-US/index.html =404;
|
|
}
|
|
location = /testnet/api/ {
|
|
#return 302 https://mempool.space/$request_uri;
|
|
try_files $uri $uri/ /en-US/index.html =404;
|
|
}
|
|
location = /bisq/api {
|
|
#return 302 https://mempool.space/$request_uri;
|
|
try_files $uri $uri/ /en-US/index.html =404;
|
|
}
|
|
location = /bisq/api/ {
|
|
#return 302 https://mempool.space/$request_uri;
|
|
try_files $uri $uri/ /en-US/index.html =404;
|
|
}
|
|
|
|
# mainnet API
|
|
location /api/v1/donations {
|
|
proxy_pass http://127.0.0.1:8999;
|
|
# don't rate limit this API prefix
|
|
}
|
|
location /api/v1/donations/images {
|
|
proxy_pass http://127.0.0.1:8999;
|
|
proxy_cache cache;
|
|
proxy_cache_valid 200 1d;
|
|
}
|
|
location /api/v1/ws {
|
|
proxy_pass http://127.0.0.1:8999/;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection "Upgrade";
|
|
}
|
|
location /api/v1 {
|
|
proxy_pass http://127.0.0.1:8999/api/v1;
|
|
limit_req burst=50 nodelay zone=api;
|
|
}
|
|
location /api/ {
|
|
proxy_pass http://[::1]:3000/;
|
|
limit_req burst=50 nodelay zone=electrs;
|
|
}
|
|
|
|
# liquid API
|
|
location /liquid/api/v1/ws {
|
|
proxy_pass http://127.0.0.1:8998/;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection "Upgrade";
|
|
}
|
|
location /liquid/api/v1 {
|
|
proxy_pass http://127.0.0.1:8998/api/v1;
|
|
limit_req burst=50 nodelay zone=api;
|
|
}
|
|
location /liquid/api/ {
|
|
proxy_pass http://[::1]:3001/;
|
|
limit_req burst=50 nodelay zone=electrs;
|
|
}
|
|
|
|
# testnet API
|
|
location /testnet/api/v1/ws {
|
|
proxy_pass http://127.0.0.1:8997/;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection "Upgrade";
|
|
}
|
|
location /testnet/api/v1 {
|
|
proxy_pass http://127.0.0.1:8997/api/v1;
|
|
limit_req burst=50 nodelay zone=api;
|
|
}
|
|
location /testnet/api/ {
|
|
proxy_pass http://[::1]:3002/;
|
|
limit_req burst=50 nodelay zone=electrs;
|
|
}
|
|
|
|
# bisq API
|
|
location /bisq/api/v1/ws {
|
|
proxy_pass http://127.0.0.1:8996/;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection "Upgrade";
|
|
}
|
|
location /bisq/api/v1/markets {
|
|
proxy_pass http://127.0.0.1:8996/api/v1/bisq/markets;
|
|
#limit_req burst=50 nodelay zone=api;
|
|
}
|
|
location /bisq/api/v1 {
|
|
proxy_pass http://127.0.0.1:8996/api/v1;
|
|
limit_req burst=50 nodelay zone=api;
|
|
}
|
|
location /bisq/api {
|
|
proxy_pass http://127.0.0.1:8996/api/v1/bisq;
|
|
limit_req burst=50 nodelay zone=api;
|
|
}
|
|
|
|
# mainnet API
|
|
location /ws {
|
|
proxy_pass http://127.0.0.1:8999/;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection "Upgrade";
|
|
}
|
|
location /ws/mainnet {
|
|
proxy_pass http://127.0.0.1:8999/;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection "Upgrade";
|
|
}
|
|
location /ws/liquid {
|
|
proxy_pass http://127.0.0.1:8998/;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection "Upgrade";
|
|
}
|
|
location /ws/testnet {
|
|
proxy_pass http://127.0.0.1:8997/;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection "Upgrade";
|
|
}
|