Skip to content
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

i18n has been changed #78

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/app.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* globals lang */
import 'i18n/i18n'; // Generates global lang object
import 'i18n'; // Generates global lang object
import '@smartface/native';
import 'theme';
import 'lib/deeplink';
Expand Down
27 changes: 14 additions & 13 deletions scripts/components/FlLogin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { EMAIL_REGEXP, MINIMUM_CHARACTERS_REQUIRED_FOR_PASSWORD } from 'constant
import { hideWaitDialog, showWaitDialog } from 'lib/waitDialog';
import { NativeStackRouter, Router } from '@smartface/router';
import { login } from 'service/auth';
import { i18n } from '@smartface/i18n';

export default class FlLogin extends FlLoginDesign {
pageName?: string | undefined;
Expand All @@ -17,12 +18,12 @@ export default class FlLogin extends FlLoginDesign {
this.btnLogin.on('press', () => {
this.initUserLogin();
});
this.lblTitle.text = global.lang.login;
this.lblText.text = global.lang.loginSubText;
this.btnLogin.text = global.lang.login;
this.lblForgetPassword.text = global.lang.forgotPassword;
this.lblRouteSignUp.text = global.lang.signup;
this.lblLeft.text = global.lang.donthaveanaccount;
this.lblTitle.text = `${i18n.instance.t('login')}`;
this.lblText.text = `${i18n.instance.t('loginSubText')}`;
this.btnLogin.text = `${i18n.instance.t('login')}`;
this.lblForgetPassword.text = `${i18n.instance.t('forgotPassword')}`;
this.lblRouteSignUp.text = `${i18n.instance.t('signup')}`;
this.lblLeft.text = `${i18n.instance.t('donthaveanaccount')}`;
}
get router(): Router {
return this._router;
Expand All @@ -40,10 +41,10 @@ export default class FlLogin extends FlLoginDesign {
this.mtbPassword.android.enableErrorMessage = true;

this.mtbEmail.options = {
hint: global.lang.email
hint: `${i18n.instance.t('email')}`
};
this.mtbPassword.options = {
hint: global.lang.password
hint: `${i18n.instance.t('password')}`
};
this.mtbPassword.materialTextBox.isPassword = true;
}
Expand All @@ -62,8 +63,8 @@ export default class FlLogin extends FlLoginDesign {
}
} catch (error) {
alert({
title: global.lang.warning,
message: global.lang.userNotFoundWithThisCredentials
title: `${i18n.instance.t('warning')}`,
message: `${i18n.instance.t('userNotFoundWithThisCredentials')}`
});
} finally {
hideWaitDialog();
Expand All @@ -82,17 +83,17 @@ export default class FlLogin extends FlLoginDesign {
this.mtbEmail.materialTextBox.errorMessage = '';
} else {
this.isMailValid = false;
this.mtbEmail.materialTextBox.errorMessage = global.lang.invalidEmail;
this.mtbEmail.materialTextBox.errorMessage = `${i18n.instance.t('invalidEmail')}`;
}

if (passwordExists && this.mtbPassword.materialTextBox.text.length >= MINIMUM_CHARACTERS_REQUIRED_FOR_PASSWORD) {
this.isPasswordValid = true;
this.mtbPassword.materialTextBox.errorMessage = '';
} else {
this.isPasswordValid = false;
this.mtbPassword.materialTextBox.errorMessage = global.lang.minimumCharacterErrorOnPassword.replace(
this.mtbPassword.materialTextBox.errorMessage = `${i18n.instance.t('minimumCharacterErrorOnPassword')}`.replace(
'$1',
MINIMUM_CHARACTERS_REQUIRED_FOR_PASSWORD
MINIMUM_CHARACTERS_REQUIRED_FOR_PASSWORD.toString()
);
}
if (this.isMailValid && this.isPasswordValid) {
Expand Down
3 changes: 2 additions & 1 deletion scripts/components/FlRateProduct.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import ImageView from '@smartface/native/ui/imageview';
import FlRateProductDesign from 'generated/my-components/FlRateProduct';
import { i18n } from '@smartface/i18n';

export default class FlRateProduct extends FlRateProductDesign {
pageName?: string | undefined;
Expand All @@ -8,7 +9,7 @@ export default class FlRateProduct extends FlRateProductDesign {
constructor(props?: any, pageName?: string) {
super(props);
this.pageName = pageName;
this.lblHeader.text = global.lang.rateProduct;
this.lblHeader.text = `${i18n.instance.t('rateProduct')}`;
this.images = [this.imgStar1, this.imgStar2, this.imgStar3, this.imgStar4, this.imgStar5];
this.images.forEach((imageViewStar, index) => {
imageViewStar.on('touchEnded', () => {
Expand Down
37 changes: 19 additions & 18 deletions scripts/components/FlSignup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { hideWaitDialog, showWaitDialog } from 'lib/waitDialog';
import { register } from 'service/commerce';
import AttributedString from '@smartface/native/ui/attributedstring';
import { themeService } from 'theme';
import { i18n } from '@smartface/i18n';

export default class FlSignup extends FlSignupDesign {
pageName?: string | undefined;
Expand All @@ -28,9 +29,9 @@ export default class FlSignup extends FlSignupDesign {
this.mtbFirstName.materialTextBox.removeFocus();
return true;
}
this.lblTitle.text = global.lang.signup;
this.lblText.text = global.lang.signupSubText;
this.btnSignUp.text = global.lang.signup;
this.lblTitle.text = `${i18n.instance.t('signup')}`;
this.lblText.text = `${i18n.instance.t('signupSubText')}`;
this.btnSignUp.text = `${i18n.instance.t('signup')}`;

}
get router(): Router {
Expand All @@ -45,16 +46,16 @@ export default class FlSignup extends FlSignupDesign {

initMaterialBoxes(){
this.mtbFirstName.options = {
hint: global.lang.firstName
hint: `${i18n.instance.t('firstName')}`
};
this.mtbLastName.options = {
hint: global.lang.lastName
hint: `${i18n.instance.t('lastName')}`
};
this.mtbEmail.options = {
hint: global.lang.email
hint: `${i18n.instance.t('email')}`
};
this.mtbPassword.options = {
hint: global.lang.password
hint: `${i18n.instance.t('password')}`
};
this.mtbPassword.materialTextBox.isPassword = true;
}
Expand All @@ -74,8 +75,8 @@ export default class FlSignup extends FlSignupDesign {
}
} catch (error) {
alert({
title: global.lang.warning,
message: global.lang.alreadyExist
title: `${i18n.instance.t('warning')}`,
message: `${i18n.instance.t('alreadyExist')}`
});
} finally {
hideWaitDialog();
Expand All @@ -100,26 +101,26 @@ export default class FlSignup extends FlSignupDesign {
this.mtbLastName.materialTextBox.errorMessage = '';
} else {
this.namesValid = false;
this.mtbFirstName.materialTextBox.errorMessage = global.lang.invalidName.replace('$1', MINIMUM_CHARACTERS_REQUIRED);
this.mtbLastName.materialTextBox.errorMessage = global.lang.invalidName.replace('$1', MINIMUM_CHARACTERS_REQUIRED);
this.mtbFirstName.materialTextBox.errorMessage = `${i18n.instance.t('invalidName')}`.replace('$1', MINIMUM_CHARACTERS_REQUIRED.toString());
this.mtbLastName.materialTextBox.errorMessage = `${i18n.instance.t('invalidName')}`.replace('$1', MINIMUM_CHARACTERS_REQUIRED.toString());
}

if (mailExist && this.checkIsEmailValid(this.mtbEmail.materialTextBox.text)) {
this.isMailValid = true;
this.mtbEmail.materialTextBox.errorMessage = '';
} else {
this.isMailValid = false;
this.mtbEmail.materialTextBox.errorMessage = global.lang.invalidEmail;
this.mtbEmail.materialTextBox.errorMessage = `${i18n.instance.t('invalidEmail')}`;
}

if (passwordExists && this.mtbPassword.materialTextBox.text.length >= MINIMUM_CHARACTERS_REQUIRED_FOR_PASSWORD) {
this.isPasswordValid = true;
this.mtbPassword.materialTextBox.errorMessage = '';
} else {
this.isPasswordValid = false;
this.mtbPassword.materialTextBox.errorMessage = global.lang.minimumCharacterErrorOnPassword.replace(
this.mtbPassword.materialTextBox.errorMessage = `${i18n.instance.t('minimumCharacterErrorOnPassword')}`.replace(
'$1',
MINIMUM_CHARACTERS_REQUIRED_FOR_PASSWORD
MINIMUM_CHARACTERS_REQUIRED_FOR_PASSWORD.toString()
);
}
if (this.isMailValid && this.isPasswordValid) {
Expand All @@ -135,22 +136,22 @@ export default class FlSignup extends FlSignupDesign {

private initAttributedStrings() {
const termsLeft = new AttributedString({
string: global.lang.termsLeft,
string: `${i18n.instance.t('termsLeft')}`,
font: themeService.getNativeStyle('.signup.termsLeft').font,
foregroundColor: themeService.getNativeStyle('.signup.termsLeft').textColor
});
const termsRight = new AttributedString({
string: global.lang.termsRight,
string: `${i18n.instance.t('termsRight')}`,
font: themeService.getNativeStyle('.signup.termsPrivacyRight').font,
foregroundColor: themeService.getNativeStyle('.signup.termsPrivacyRight').textColor
});
const privacyLeft = new AttributedString({
string: global.lang.privacyLeft,
string: `${i18n.instance.t('privacyLeft')}`,
font: themeService.getNativeStyle('.signup.privacyLeft').font,
foregroundColor: themeService.getNativeStyle('.signup.privacyLeft').textColor
});
const privacyRight = new AttributedString({
string: global.lang.privacyRight,
string: `${i18n.instance.t('privacyRight')}`,
font: themeService.getNativeStyle('.signup.termsPrivacyRight').font,
foregroundColor: themeService.getNativeStyle('.signup.termsPrivacyRight').textColor
});
Expand Down
4 changes: 3 additions & 1 deletion scripts/components/LviAccount.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { themeService } from 'theme';
import LviAccountDesign from 'generated/my-components/LviAccount';
import { i18n } from '@smartface/i18n';

const originalHeight = themeService.getStyle('.lviAccount').height;

export default class LviAccount extends LviAccountDesign {
Expand Down Expand Up @@ -28,7 +30,7 @@ export default class LviAccount extends LviAccountDesign {
return this.lblAccountLviTitle.text;
}
set itemTitle(value: string) {
this.lblAccountLviTitle.text = global.lang[value];
this.lblAccountLviTitle.text = `${i18n.instance.t(`${value}`)}`;
}
get leftIcon(): string {
return this.lblAccountLeftIcon.text;
Expand Down
4 changes: 2 additions & 2 deletions scripts/i18n/de.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SMF.i18n.defineLanguage('de', {
export default {
cancel: 'Stornieren',
copy: 'Kopieren',
done: 'Übersetzung',
Expand All @@ -13,4 +13,4 @@ SMF.i18n.defineLanguage('de', {
sureToDelete: 'Sind Sie sicher zu löschen?',
networkError: 'Es hat einen Netzwerkfehler, bitte versuchen Sie es später noch einmal',
applicationError: 'Es ist ein nicht behandelter Anwendungsfehler gewesen, informieren Sie bitte Entwickler'
});
};
4 changes: 2 additions & 2 deletions scripts/i18n/en.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SMF.i18n.defineLanguage('en', {
export default {
verificationCode: 'Verification Code',
productDetail: 'Product Detail',
goToCheckout: 'Go to Checkout',
Expand Down Expand Up @@ -166,4 +166,4 @@ SMF.i18n.defineLanguage('en', {
trackOrder: 'Track Order',
backHome: 'Back to home',
checkoutLoginError: 'You must be logged in to go to the checkout page.'
});
};
4 changes: 2 additions & 2 deletions scripts/i18n/fi.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SMF.i18n.defineLanguage('fi', {
export default {
cancel: 'Keskeytä',
copy: 'Kopioi',
done: 'Käännös ',
Expand All @@ -13,4 +13,4 @@ SMF.i18n.defineLanguage('fi', {
sureToDelete: 'Haluatko varmasti poistaa?',
networkError: 'Tapahtui verkkovirhe. Yritä myöhemmin uudelleen',
applicationError: 'Tapahtui käsittelemätön virhe. Ilmoita sovelluksen kehittäjille'
});
};
50 changes: 0 additions & 50 deletions scripts/i18n/i18n.ts

This file was deleted.

26 changes: 26 additions & 0 deletions scripts/i18n/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import de from './de';
import en from './en';
import fi from './fi';
import tr from './tr';
import { i18n } from '@smartface/i18n';
import System from '@smartface/native/device/system';

new i18n({
lng: Device.language,
debug: !!System.isEmulator,
resources: {
en: {
translation: en
},
tr: {
translation: tr
},
de: {
translation: de
},
fi: {
translation: fi
}
},
fallbackLng: 'en'
});
4 changes: 2 additions & 2 deletions scripts/i18n/tr.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SMF.i18n.defineLanguage('tr', {
export default {
verificationCode: 'Doğrulama Kodu',
productDetail: 'Ürün Detayı',
goToCheckout: 'Ödemeye Git',
Expand Down Expand Up @@ -165,4 +165,4 @@ SMF.i18n.defineLanguage('tr', {
trackOrder: 'Siparişi takip et',
backHome: 'Anasayfaya geri dön',
checkoutLoginError: 'Ödeme sayfasına gitmek için giriş yapmalısınız.'
});
};
15 changes: 8 additions & 7 deletions scripts/lib/checkoutDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@ import router from 'routes';
import store from 'store/index';
import storeActions from 'store/main/actions';
import { CheckoutListItem } from 'types';
import { i18n } from '@smartface/i18n';

let checkoutDialog = null;
let activeDialogCounter = 0;

function initDialog(totalCost: string | number) {
const checkoutListItems: CheckoutListItem[] = [
{ title: global.lang.delivery, description: 'Home' },
{ title: global.lang.payment, description: global.lang.payAtTheDoor },
{ title: global.lang.promoCode, description: 'No Promo Code' },
{ title: global.lang.totalCost, description: totalCost.toString() }
{ title: `${i18n.instance.t('delivery')}`, description: 'Home' },
{ title: `${i18n.instance.t('payment')}`, description: `${i18n.instance.t('payAtTheDoor')}` },
{ title: `${i18n.instance.t('promoCode')}`, description: 'No Promo Code' },
{ title: `${i18n.instance.t('totalCost')}`, description: totalCost.toString() }
]
let dialog = new Dialog({
android: {
Expand All @@ -26,9 +27,9 @@ function initDialog(totalCost: string | number) {

const component = new FlCheckout();
component.items = checkoutListItems;
component.lblCheckout.text = global.lang.checkout;
component.lblTermsAndCond.text = global.lang.checkoutTermsAndCond;
component.btnPlaceOrder.text = global.lang.placeOrder;
component.lblCheckout.text = `${i18n.instance.t('checkout')}`;
component.lblTermsAndCond.text = `${i18n.instance.t('checkoutTermsAndCond')}`;
component.btnPlaceOrder.text = `${i18n.instance.t('placeOrder')}`;
component.lblDissmisIcon.onTouchEnded = () => {
hideCheckoutDialog();
return true;
Expand Down
Loading