Skip to content

Commit

Permalink
v3.2.6
Browse files Browse the repository at this point in the history
  • Loading branch information
mytonwalletorg committed Jan 6, 2025
1 parent 4f5ccff commit 10049f1
Show file tree
Hide file tree
Showing 90 changed files with 1,698 additions and 1,029 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ MyTonWallet-opera.zip
.vscode
*.iml
dev/perf/screenshot*
dev/locales/input.yaml
dev/locales/output.yaml
.DS_store
.DS_Store
test-results
Expand Down
13 changes: 8 additions & 5 deletions capacitor.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { CapacitorConfig } from '@capacitor/cli';
import type { KeyboardResize } from '@capacitor/keyboard';

const { APP_ENV = 'production' } = process.env;

Expand All @@ -10,6 +11,7 @@ const COMMON_PLUGINS = [
'@capacitor/clipboard',
'@capacitor/filesystem',
'@capacitor/haptics',
'@capacitor/keyboard',
'@capacitor/push-notifications',
'@capacitor/share',
'@capgo/capacitor-native-biometric',
Expand All @@ -29,10 +31,6 @@ const IOS_PLUGINS = [
'@sina_kh/mtw-capacitor-splash-screen',
];

const ANDROID_PLUGINS = [
'@capacitor/keyboard',
];

const config: CapacitorConfig = {
appId: 'org.mytonwallet.app',
appName: 'MyTonWallet',
Expand All @@ -43,7 +41,7 @@ const config: CapacitorConfig = {
},
android: {
path: 'mobile/android',
includePlugins: COMMON_PLUGINS.concat(ANDROID_PLUGINS),
includePlugins: COMMON_PLUGINS,
webContentsDebuggingEnabled: APP_ENV !== 'production',
},
ios: {
Expand All @@ -62,6 +60,11 @@ const config: CapacitorConfig = {
PushNotifications: {
presentationOptions: [],
},
Keyboard: {
// Needed to disable the automatic focus scrolling on iOS. The scroll is controlled manually by focusScroll.ts
// for a better focus scroll control.
resize: 'none' as KeyboardResize,
},
},
};

Expand Down
1 change: 1 addition & 0 deletions changelogs/3.2.6.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Bug fixes and performance improvements
25 changes: 25 additions & 0 deletions dev/locales/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# i18n helpers

Scripts for managing i18n translation keys and YAML files.

## Features
1. **Extract Missing Translations**: Scans `src/` for `lang('key')` patterns and identifies missing translations in `src/i18n/`.
2. **Update Locales**: Merges new translations from `dev/locales/input.yaml` into YAML files in `src/i18n/`.

## Usage

### Extract Missing Translations
1. Run `npm run i18n:findMissing`

2. Missing keys are written to `output.yaml`.

### Update Locales
1. Add translations to `dev/locales/input.yaml`:
```yaml
en:
$key: "English text"
de:
$key: "German text"
```
2. Run `npm run i18n:update`
3 changes: 3 additions & 0 deletions dev/locales/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const i18nDir = './src/i18n';

module.exports = { i18nDir };
79 changes: 79 additions & 0 deletions dev/locales/findMissingKeys.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
const fs = require('fs');
const path = require('path');
const yaml = require('js-yaml');
const { i18nDir } = require('./config');

const outputFilePath = path.resolve(__dirname, 'output.yaml');
const srcDir = './src';

function extractLangKeys(dir) {
const langKeys = new Set();

function traverse(directory) {
const files = fs.readdirSync(directory);

files.forEach((file) => {
const fullPath = path.join(directory, file);
const stat = fs.statSync(fullPath);

if (stat.isDirectory()) {
traverse(fullPath);
} else if (file.endsWith('.ts') || file.endsWith('.tsx') || file.endsWith('.js') || file.endsWith('.jsx')) {
const content = fs.readFileSync(fullPath, 'utf8');

const matches = content.matchAll(/lang\(\s*(['"`])((?:\\.|[^\\])*?)\1(?:,|\))/gs);

for (const match of matches) {
let key = match[2];

key = key.replace(/\\'/g, "'").replace(/\\"/g, '"').replace(/\\n/g, '\n');

langKeys.add(key);
}
}
});
}

traverse(dir);
return langKeys;
}

function findMissingTranslations(langKeys, i18nDir) {
const missingTranslations = {};

const localeFiles = fs.readdirSync(i18nDir).filter((file) => file.endsWith('.yaml'));

localeFiles.forEach((file) => {
const lang = path.basename(file, '.yaml');
const filePath = path.join(i18nDir, file);
const translations = yaml.load(fs.readFileSync(filePath, 'utf8')) || {};

langKeys.forEach((key) => {
if (!translations[key]) {
if (!missingTranslations[lang]) {
missingTranslations[lang] = {};
}
missingTranslations[lang][key] = key;
}
});
});

return missingTranslations;
}

function writeMissingTranslations(missingTranslations, outputFilePath) {
const yamlContent = yaml.dump(missingTranslations, { noRefs: true, indent: 2 });
fs.writeFileSync(outputFilePath, yamlContent, 'utf8');
console.log(`Missing translations written to ${outputFilePath}`);
}

(function main() {
console.log('Extracting lang keys from source code...');
const langKeys = extractLangKeys(srcDir);

console.log('Checking for missing translations...');
const missingTranslations = findMissingTranslations(langKeys, i18nDir);

console.log('Writing missing translations to output file...');
writeMissingTranslations(missingTranslations, outputFilePath);
})();
46 changes: 46 additions & 0 deletions dev/locales/updateLocales.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
const fs = require('fs');
const path = require('path');
const yaml = require('js-yaml');
const { i18nDir } = require('./config');

const inputFilePath = path.resolve(__dirname, 'input.yaml');

function updateYamlFiles() {
try {
const inputContent = fs.readFileSync(inputFilePath, 'utf8');
const inputData = yaml.load(inputContent);

for (const lang in inputData) {
const langData = inputData[lang];
const yamlFilePath = path.join(i18nDir, `${lang}.yaml`);

let existingData = {};

if (fs.existsSync(yamlFilePath)) {
const existingContent = fs.readFileSync(yamlFilePath, 'utf8');
existingData = yaml.load(existingContent) || {};
}

const updatedData = {
...existingData,
...langData,
};

const updatedYaml = yaml.dump(updatedData, {
noRefs: true,
indent: 2,
lineWidth: -1,
quotingType: '"',
});
fs.writeFileSync(yamlFilePath, updatedYaml, 'utf8');

console.log(`Updated: ${yamlFilePath}`);
}

console.log('All YAML files have been updated.');
} catch (error) {
console.error('Error updating YAML files:', error);
}
}

updateYamlFiles();
2 changes: 1 addition & 1 deletion mobile/android/app/capacitor.build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ dependencies {
implementation project(':capacitor-clipboard')
implementation project(':capacitor-filesystem')
implementation project(':capacitor-haptics')
implementation project(':capacitor-keyboard')
implementation project(':capacitor-push-notifications')
implementation project(':capacitor-share')
implementation project(':capgo-capacitor-native-biometric')
Expand All @@ -28,7 +29,6 @@ dependencies {
implementation project(':mtw-capacitor-usb-hid')
implementation project(':native-bottom-sheet')
implementation project(':native-dialog')
implementation project(':capacitor-keyboard')

}

Expand Down
6 changes: 3 additions & 3 deletions mobile/android/capacitor.settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ project(':capacitor-filesystem').projectDir = new File('../../node_modules/@capa
include ':capacitor-haptics'
project(':capacitor-haptics').projectDir = new File('../../node_modules/@capacitor/haptics/android')

include ':capacitor-keyboard'
project(':capacitor-keyboard').projectDir = new File('../../node_modules/@capacitor/keyboard/android')

include ':capacitor-push-notifications'
project(':capacitor-push-notifications').projectDir = new File('../../node_modules/@capacitor/push-notifications/android')

Expand Down Expand Up @@ -58,6 +61,3 @@ project(':native-bottom-sheet').projectDir = new File('../plugins/native-bottom-

include ':native-dialog'
project(':native-dialog').projectDir = new File('../plugins/native-dialog/android')

include ':capacitor-keyboard'
project(':capacitor-keyboard').projectDir = new File('../../node_modules/@capacitor/keyboard/android')
1 change: 1 addition & 0 deletions mobile/ios/App/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def capacitor_pods
pod 'CapacitorClipboard', :path => '../../../node_modules/@capacitor/clipboard'
pod 'CapacitorFilesystem', :path => '../../../node_modules/@capacitor/filesystem'
pod 'CapacitorHaptics', :path => '../../../node_modules/@capacitor/haptics'
pod 'CapacitorKeyboard', :path => '../../../node_modules/@capacitor/keyboard'
pod 'CapacitorPushNotifications', :path => '../../../node_modules/@capacitor/push-notifications'
pod 'CapacitorShare', :path => '../../../node_modules/@capacitor/share'
pod 'CapgoCapacitorNativeBiometric', :path => '../../../node_modules/@capgo/capacitor-native-biometric'
Expand Down
8 changes: 7 additions & 1 deletion mobile/ios/App/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ PODS:
- Capacitor
- CapacitorHaptics (6.0.1):
- Capacitor
- CapacitorKeyboard (6.0.3):
- Capacitor
- CapacitorMlkitBarcodeScanning (6.2.0):
- Capacitor
- GoogleMLKit/BarcodeScanning (= 5.0.0)
Expand Down Expand Up @@ -152,6 +154,7 @@ DEPENDENCIES:
- "CapacitorCordova (from `../../../node_modules/@capacitor/ios`)"
- "CapacitorFilesystem (from `../../../node_modules/@capacitor/filesystem`)"
- "CapacitorHaptics (from `../../../node_modules/@capacitor/haptics`)"
- "CapacitorKeyboard (from `../../../node_modules/@capacitor/keyboard`)"
- "CapacitorMlkitBarcodeScanning (from `../../../node_modules/@capacitor-mlkit/barcode-scanning`)"
- CapacitorNativeSettings (from `../../../node_modules/capacitor-native-settings`)
- CapacitorPluginSafeArea (from `../../../node_modules/capacitor-plugin-safe-area`)
Expand Down Expand Up @@ -207,6 +210,8 @@ EXTERNAL SOURCES:
:path: "../../../node_modules/@capacitor/filesystem"
CapacitorHaptics:
:path: "../../../node_modules/@capacitor/haptics"
CapacitorKeyboard:
:path: "../../../node_modules/@capacitor/keyboard"
CapacitorMlkitBarcodeScanning:
:path: "../../../node_modules/@capacitor-mlkit/barcode-scanning"
CapacitorNativeSettings:
Expand Down Expand Up @@ -255,6 +260,7 @@ SPEC CHECKSUMS:
CapacitorCordova: f48c89f96c319101cd2f0ce8a2b7449b5fb8b3dd
CapacitorFilesystem: 37fb3aa5c945b4539ab11c74a5c57925a302bf24
CapacitorHaptics: fe689ade56ef20ec9b041a753c6da70c5d8ec9a9
CapacitorKeyboard: 460c6f9ec5e52c84f2742d5ce2e67bbc7ab0ebb0
CapacitorMlkitBarcodeScanning: 178fb57424ec688b6a2fceee506ecc1ea00d1c8d
CapacitorNativeSettings: 1ce5585ff07b161616cd0a795702637316677af2
CapacitorPluginSafeArea: e1eca7f70974f0e270d96f70cd0a5f51523164b1
Expand Down Expand Up @@ -289,6 +295,6 @@ SPEC CHECKSUMS:
SinaKhMtwCapacitorStatusBar: e3fa73038e8dbac071751e1942eab65fc6c39a5f
SwiftKeychainWrapper: 807ba1d63c33a7d0613288512399cd1eda1e470c

PODFILE CHECKSUM: ad14d80bb92e306162432517de945467c60b7527
PODFILE CHECKSUM: fa64166a091f354ce503fdaf4d4b36e1cc75b934

COCOAPODS: 1.16.2
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.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mytonwallet",
"version": "3.2.5",
"version": "3.2.6",
"description": "The most feature-rich web wallet and browser extension for TON – with support of multi-accounts, tokens (jettons), NFT, TON DNS, TON Sites, TON Proxy, and TON Magic.",
"main": "index.js",
"scripts": {
Expand Down Expand Up @@ -43,7 +43,9 @@
"giveaways:build": "webpack --config ./webpack-giveaways.config.ts && bash ./deploy/copy_to_dist.sh dist-giveaways",
"giveaways:build:dev": "APP_ENV=development webpack --mode development --config ./webpack-giveaways.config.ts && bash ./deploy/copy_to_dist.sh dist-giveaways",
"giveaways:dev": "APP_ENV=development webpack serve --mode development --port 4322 --config ./webpack-giveaways.config.ts",
"resolve-stacktrace": "node ./dev/resolveStackTrace.js"
"resolve-stacktrace": "node ./dev/resolveStackTrace.js",
"i18n:update": "node ./dev/locales/updateLocales.js",
"i18n:find-missing": "node ./dev/locales/findMissingKeys.js"
},
"engines": {
"node": "^22",
Expand Down
2 changes: 2 additions & 0 deletions public/static-sites/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
index.css
bg
images
common.js
!_common/*
32 changes: 32 additions & 0 deletions public/static-sites/_common/common.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
function getPlatform() {
const {
userAgent,
platform,
} = window.navigator;

const iosPlatforms = ['iPhone', 'iPad', 'iPod'];
if (
iosPlatforms.indexOf(platform) !== -1
// For new IPads with M1 chip and IPadOS platform returns "MacIntel"
|| (platform === 'MacIntel' && ('maxTouchPoints' in navigator && navigator.maxTouchPoints > 2))
) {
return 'iOS';
}

const macosPlatforms = ['Macintosh', 'MacIntel', 'MacPPC', 'Mac68K'];
if (macosPlatforms.indexOf(platform) !== -1) return 'macOS';

const windowsPlatforms = ['Win32', 'Win64', 'Windows', 'WinCE'];
if (windowsPlatforms.indexOf(platform) !== -1) return 'Windows';

if (/Android/.test(userAgent)) return 'Android';

if (/Linux/.test(platform)) return 'Linux';

return undefined;
}

export let platform = getPlatform();

export const IS_DESKTOP = ['Windows', 'Linux', 'macOS'].includes(platform);
export const IS_MOBILE = !IS_DESKTOP;
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 10049f1

Please sign in to comment.