You've already forked tf2wikipricing
fix, feat: add currency conversion stub
uses proper JS api for currency formatting and preparations for showing other currencies based on page locale
This commit is contained in:
@@ -1,8 +1,47 @@
|
||||
import { conversion_ref_usd } from '../config';
|
||||
|
||||
export function defaultCurrencyForPageLocale(locale: string): string | null {
|
||||
switch (locale) {
|
||||
case 'de':
|
||||
case 'fr':
|
||||
case 'it':
|
||||
case 'nl':
|
||||
case 'hu':
|
||||
return 'EUR';
|
||||
case 'ja':
|
||||
return 'JPY';
|
||||
case 'tr':
|
||||
return 'TRY';
|
||||
case 'da':
|
||||
return 'DKK';
|
||||
case 'pt-br':
|
||||
return 'BRL';
|
||||
case 'zh-hans':
|
||||
case 'zh-hant':
|
||||
return 'CNY';
|
||||
case 'ko':
|
||||
return 'KRW';
|
||||
case 'cs':
|
||||
return 'CZK';
|
||||
case 'ru':
|
||||
return 'RUB';
|
||||
case 'pl':
|
||||
return 'PLN';
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export function convertTF2PriceToUSD(keys: number, metal: number, keyPrice: number): number {
|
||||
const pureMetal = (keys * keyPrice) + metal;
|
||||
|
||||
// Round price up to nearest cent
|
||||
return Math.ceil(pureMetal * conversion_ref_usd * 100) / 100
|
||||
}
|
||||
|
||||
export function convertUSD(usd: number, currency: string): number {
|
||||
const cur = currency.toUpperCase()
|
||||
if(cur === 'USD') return usd
|
||||
|
||||
throw new Error(`Not implemented`)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user