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

Add Persian Translation #882

Open
wants to merge 10 commits into
base: master
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 .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports = {
'no-console': 'warn',
'no-debugger': 'warn',
'arrow-body-style': 'off',
'prettier/prettier': 'warn',
'prettier/prettier': ['warn', {"endOfLine": "auto" }]
'prefer-arrow-callback': 'warn',
'vue/no-mutating-props': 'off',
'vue/multi-word-component-names': 'off',
Expand Down
2 changes: 1 addition & 1 deletion fyo/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ export class Fyo {

store = {
isDevelopment: false,
skipTelemetryLogging: false,
skipTelemetryLogging: true,
appVersion: '',
platform: '',
language: '',
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"pesa": "^1.1.12",
"source-map-support": "^0.5.21",
"vue": "^3.2.40",
"vue-router": "^4.0.12"
"vue-router": "^4.0.12",
"vue3-persian-datetime-picker": "^1.2.2"
},
"devDependencies": {
"@codemirror/language": "^6.0.0",
Expand Down
47 changes: 40 additions & 7 deletions src/components/Controls/Date.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,28 @@
</div>
<input
v-show="showInput"
:id="componentID"
ref="input"
:class="[inputClasses, containerClasses]"
:type="inputType"
type="text"
:value="inputValue"
:placeholder="inputPlaceholder"
:readonly="isReadOnly"
:tabindex="isReadOnly ? '-1' : '0'"
@blur="onBlur"
@focus="onFocus"
@input="(e) => $emit('input', e)"
/>

<date-picker
v-show="showInput"
ref="persianDatePicker"
@close="showInput=false"
@change="onChange"
v-model="selectedDate"
format="YYYY-MM-DD"
:show = "showInput"
:custom-input="datePickerID"
locale="fa,en"
/>

<div
v-show="!showInput"
class="flex"
Expand Down Expand Up @@ -48,17 +59,29 @@
<script lang="ts">
import { DateTime } from 'luxon';
import { fyo } from 'src/initFyo';
import { defineComponent, nextTick } from 'vue';
import { defineComponent, nextTick} from 'vue';
import Base from './Base.vue';
import DatePicker from 'vue3-persian-datetime-picker';

let uidCounter = 0;

export default defineComponent({
extends: Base,
name: "Date",
emits: ['input', 'focus'],
data() {
return {
showInput: false,
selectedDate: this.value,
componentID: '',
datePickerID: '',
};
},
mounted (){
this.componentID = this.$options.name + '-' + uidCounter++;
this.datePickerID = '#' + this.componentID;
},
components: { DatePicker },
computed: {
inputValue(): string {
let value = this.value;
Expand All @@ -77,7 +100,8 @@ export default defineComponent({
},
formattedValue() {
const value = this.parse(this.value);
return fyo.format(value, this.df, this.doc);
//return fyo.format(value, this.df, this.doc);
return new Date(fyo.format(value, this.df, this.doc)).toLocaleDateString('fa-IR');
},
borderClasses(): string {
if (!this.border) {
Expand All @@ -98,6 +122,15 @@ export default defineComponent({
},
},
methods: {
onChange(e: Event){
const target = e.target;
this.showInput = false;
let value: Date | null = DateTime.fromISO(e.toISOString()).toJSDate();
if (Number.isNaN(value.valueOf())) {
value = null;
}
this.triggerChange(value);
},
onFocus(e: FocusEvent) {
const target = e.target;
if (!(target instanceof HTMLInputElement)) {
Expand Down Expand Up @@ -132,7 +165,7 @@ export default defineComponent({
this.focus();

// @ts-ignore
this.$refs.input.showPicker();
//this.$refs.input.showPicker();
});
},
},
Expand Down
2 changes: 1 addition & 1 deletion src/components/Report/ListReport.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"
:class="[getCellColorClass(cell)]"
>
{{ cell.value }}
{{ (cell.rawValue instanceof Date) ? new Date(cell.value).toLocaleDateString('fa-IR') : cell.value }}
</div>
</div>
</template>
Expand Down
4 changes: 2 additions & 2 deletions src/pages/PrintView/ReportPrintView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@

<div class="border-t p-2">
<p class="text-xs text-right w-full">
{{ fyo.format(new Date(), 'Datetime') }}
{{ new Date(fyo.format(new Date(), 'Datetime')).toLocaleDateString('fa-IR') }}
</p>
</div>
</div>
Expand Down Expand Up @@ -273,7 +273,7 @@ export default defineComponent({
return;
}

const name = this.title + ' - ' + this.fyo.format(new Date(), 'Date');
const name = this.title + ' - ' + new Date(this.fyo.format(new Date(), 'Date')).toLocaleDateString('fa-IR');
await getPathAndMakePDF(
name,
innerHTML,
Expand Down
1 change: 1 addition & 0 deletions src/utils/language.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const languageCodeMap: Record<string, string> = {
Gujarati: 'gu',
Korean: 'ko',
Nepali: 'np',
Persian: 'fa-IR',
Portuguese: 'pt',
'Simplified Chinese': 'zh-CN',
Spanish: 'es',
Expand Down
2 changes: 1 addition & 1 deletion tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = {
purge: false,
theme: {
fontFamily: {
sans: ['Inter', 'sans-serif'],
sans: ['Vazirmatn UI FD', 'Tahoma'],
},
screens: {
sm: '640px',
Expand Down
62 changes: 37 additions & 25 deletions templates/Basic.template.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
<main class="bg-white h-full px-6" :style="{ 'font-family': print.font }">
<main class="bg-white h-full px-6" :style="{ 'font-family': 'Vazirmatn UI FD', 'direction': 'rtl' }">

<div v-if="!doc.submitted" :style="{
'position': 'absolute',
'top': '50%',
'left': '50%',
'transform': 'translate(-50%, -50%) rotate(-45deg) scaleX(8.5) scaleY(6)',
'font-size': '24px',
'color': 'rgba(0, 0, 0, 0.1)'
}">
پیش فاکتور
</div>

<!-- Invoice Header -->
<header class="py-6 flex text-sm text-gray-900 border-b">
<!-- Company Logo & Name -->
<section class="w-1/3">
<img
v-if="print.displayLogo"
class="h-12 max-w-32 object-contain"
class="h-14 max-w-32 object-contain"
:src="print.logo"
/>
<div class="text-xl text-gray-700 font-semibold" v-else>
Expand All @@ -15,13 +27,13 @@

<!-- Company Contacts -->
<section class="w-1/3">
<div>{{ print.email }}</div>
<div class="mt-1">{{ print.phone }}</div>
<div>ایمیل: {{ print.email }}</div>
<div class="mt-1">همراه: {{ print.phone }}</div>
</section>

<!-- Company Address & GSTIN -->
<section class="w-1/3">
<div v-if="print.address">{{ print.links.address.addressDisplay }}</div>
<div v-if="print.address">{{ print.links.address.addressDisplay.replace(', Iran','') }}</div>
<div v-if="print.gstin">GSTIN: {{ print.gstin }}</div>
</section>
</header>
Expand All @@ -31,7 +43,7 @@
<!-- Invoice Details -->
<section class="w-1/3">
<h2 class="text-2xl font-semibold">{{ doc.name }}</h2>
<p class="py-2 text-base">{{ doc.date }}</p>
<p class="py-2 text-base">{{new Date(doc.date).toLocaleDateString('fa-IR') }}</p>
</section>

<!-- Party Details -->
Expand All @@ -41,7 +53,7 @@ <h2 class="py-1 text-right text-lg font-semibold">{{ doc.party }}</h2>
v-if="doc.links.party.address"
class="mt-1 text-xs text-gray-600 text-right"
>
{{ doc.links.party.links.address.addressDisplay }}
{{ doc.links.party.links.address.addressDisplay.replace(', Iran','') }}
</p>
<p
v-if="doc.links.party.gstin"
Expand All @@ -56,13 +68,13 @@ <h2 class="py-1 text-right text-lg font-semibold">{{ doc.party }}</h2>
<section class="mt-8 text-base">
<!-- Heading Row -->
<section class="text-gray-600 w-full flex border-b">
<div class="py-4 w-5/12">{{ t`Item` }}</div>
<div class="py-4 text-right w-2/12" v-if="doc.showHSN">
<div class="py-2 w-5/12">نام کالا/خدمات</div>
<div class="py-2 text-right w-2/12" v-if="doc.showHSN">
{{ t`HSN/SAC` }}
</div>
<div class="py-4 text-right w-1/12">{{ t`Quantity` }}</div>
<div class="py-4 text-right w-3/12">{{ t`Rate` }}</div>
<div class="py-4 text-right w-3/12">{{ t`Amount` }}</div>
<div class="py-2 text-right w-1/12">تعداد</div>
<div class="py-2 text-right w-3/12">قیمت واحد</div>
<div class="py-2 text-right w-3/12">جمع کل</div>
</section>

<!-- Body Rows -->
Expand All @@ -71,13 +83,13 @@ <h2 class="py-1 text-right text-lg font-semibold">{{ doc.party }}</h2>
v-for="row in doc.items"
:key="row.name"
>
<div class="w-5/12 py-4">{{ row.item }}</div>
<div class="w-5/12 py-2">{{ row.item }}</div>
<div class="w-2/12 text-right py-4" v-if="doc.showHSN">
{{ row.hsnCode }}
</div>
<div class="w-1/12 text-right py-4">{{ row.quantity }}</div>
<div class="w-3/12 text-right py-4">{{ row.rate }}</div>
<div class="w-3/12 text-right py-4">{{ row.amount }}</div>
<div class="w-1/12 text-right py-2">{{ row.quantity }}</div>
<div class="w-3/12 text-right py-2">{{ row.rate.replace('﷼','') + " ریال" }}</div>
<div class="w-3/12 text-right py-2" style="text-direction:right">{{ row.amount.replace('﷼','') + " ریال" }}</div>
</section>
</section>

Expand All @@ -86,7 +98,7 @@ <h2 class="py-1 text-right text-lg font-semibold">{{ doc.party }}</h2>
<!-- Invoice Terms -->
<section class="w-1/2">
<h3 class="text-sm tracking-widest text-gray-600 mt-2" v-if="doc.terms">
{{ t`Notes` }}
توضیحات
</h3>
<p class="my-4 text-lg whitespace-pre-line">{{ doc.terms }}</p>
</section>
Expand All @@ -95,17 +107,17 @@ <h3 class="text-sm tracking-widest text-gray-600 mt-2" v-if="doc.terms">
<section class="w-1/2">
<!-- Subtotal -->
<div class="flex pl-2 justify-between py-3 border-b">
<h3>{{ t`Subtotal` }}</h3>
<p>{{ doc.netTotal }}</p>
<h3>جمع</h3>
<p>{{ doc.netTotal.replace('﷼','') + " ریال" }}</p>
</div>

<!-- Discount (if applied before tax) -->
<div
class="flex pl-2 justify-between py-3 border-b"
v-if="doc.totalDiscount && !doc.discountAfterTax"
>
<h3>{{ t`Discount` }}</h3>
<p>{{ doc.totalDiscount }}</p>
<h3>تخفیف</h3>
<p>{{ doc.totalDiscount.replace('﷼','') + " ریال" }}</p>
</div>

<!-- Tax Breakdown -->
Expand All @@ -123,7 +135,7 @@ <h3>{{ tax.account }}</h3>
class="flex pl-2 justify-between py-3 border-t"
v-if="doc.totalDiscount && doc.discountAfterTax"
>
<h3>{{ t`Discount` }}</h3>
<h3>تخفیف</h3>
<p>{{ doc.totalDiscount }}</p>
</div>

Expand All @@ -140,9 +152,9 @@ <h3>{{ t`Discount` }}</h3>
text-base
"
>
<h3>{{ t`Grand Total` }}</h3>
<p>{{ doc.grandTotal }}</p>
<h3>مبلغ نهایی</h3>
<p>{{ doc.grandTotal.replace('﷼','') + " ریال" }}</p>
</div>
</section>
</footer>
</main>
</main>
Loading