Skip to content

Commit bc581eb

Browse files
authored
Merge pull request vuejs#74 from ousszizou/guide/scaling-up/sfc
translate(scaling-up): SFC
2 parents c772427 + bd7a4d2 commit bc581eb

File tree

1 file changed

+29
-31
lines changed

1 file changed

+29
-31
lines changed

src/guide/scaling-up/sfc.md

Lines changed: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# Single-File Components {#single-file-components}
1+
# المكونات أحادية الملف {#single-file-components}
22

3-
## Introduction {#introduction}
3+
## مقدمة {#introduction}
44

5-
Vue Single-File Components (a.k.a. `*.vue` files, abbreviated as **SFC**) is a special file format that allows us to encapsulate the template, logic, **and** styling of a Vue component in a single file. Here's an example SFC:
5+
مكونات vue أحادية الملف ( التي تُسمَّى أو تُعرف أيضا باسم ملفات `*.vue` ، و المختصرة باسم **SFC** ) هي تنسيق ملف خاص يسمح لنا بتغليف القالب، الشيفرة البرمجية و التنسيق لمُكون vue في ملف واحد. إليك مثال SFC:
66

77
<div class="options-api">
88

@@ -53,32 +53,30 @@ const greeting = ref('Hello World!')
5353

5454
</div>
5555

56-
As we can see, Vue SFC is a natural extension of the classic trio of HTML, CSS and JavaScript. The `<template>`, `<script>`, and `<style>` blocks encapsulate and colocate the view, logic and styling of a component in the same file. The full syntax is defined in the [SFC Syntax Specification](/api/sfc-spec).
56+
كما نرى ، Vue SFC هو امتداد طبيعي للثلاثي الكلاسيكي من HTML و CSS و JavaScript . تقوم الكُتل `<template>` و `<script>` و `<style> ` بتغليف و تجميع عرض و منطق و تنسيق المُكون في نفس الملف. الصيغة الكاملة مُحددة في [مواصفات صيغة SFC](/api/sfc-spec).
5757

58-
## Why SFC {#why-sfc}
58+
## لماذا SFC {#why-sfc}
5959

60-
While SFCs require a build step, there are numerous benefits in return:
60+
بينما تتطلب المكونات أحادية الملف مرحلة بناء، هنالك العديد من الفوائد بالمُقابل:
6161

62-
- Author modularized components using familiar HTML, CSS and JavaScript syntax
63-
- [Colocation of inherently coupled concerns](#what-about-separation-of-concerns)
64-
- Pre-compiled templates without runtime compilation cost
65-
- [Component-scoped CSS](/api/sfc-css-features)
66-
- [More ergonomic syntax when working with Composition API](/api/sfc-script-setup)
67-
- More compile-time optimizations by cross-analyzing template and script
68-
- [IDE support](/guide/scaling-up/tooling.html#ide-support) with auto-completion and type-checking for template expressions
69-
- Out-of-the-box Hot-Module Replacement (HMR) support
62+
- صياغة مُكونات مُركبة باستخدام صيغة HTML، CSS و JavaScript المُعتادة.
63+
- [تجميع الاهتمامات ( الجوانب و العوامل املختلفة التي يجب مُراعاتها ) المُترابطة بطبيعتها.](#what-about-separation-of-concerns)
64+
- قوالب مُصرفة مُسبقا بدون تكلفة التصريف أثناء التشغيل.
65+
- [CSS ذات نطاق المُكون ( التنسيق أو النمط يكون مُحدد بشكل خاص للمُكون ).](/api/sfc-css-features)
66+
- [صياغة أكثر سلاسة عند العمل مع الواجهة التركيبية لبرمجة التطبيقات](/api/sfc-script-setup)
67+
- المزيد من تحسينات مرحلة الترجمة عن طريق تحليل متقاطع بين القالب و المنطق البرمجي
68+
- [دعم مُحرر بيئة التطوير المتكاملة](/guide/scaling-up/tooling.html#ide-support) مع إكمال تلقائي و فحص نوع البيانات لتعبيرات القوالب.
69+
- دعم ميزة استبدال الوحدات النمطية الحية أثناء تشغيل التطبيق دون الحاجة إلى أي تهيئة إضافية.
7070

71-
SFC is a defining feature of Vue as a framework, and is the recommended approach for using Vue in the following scenarios:
71+
المكونات أحادية الملف من المميزات المحددة لـ Vue كإطار عمل، و يُعتبر النهج الموصى به لاستخدام Vue في السيناريوهات التالية:
72+
- التطبيقات أحادية الصفحة ( SPA )
73+
- مولدات مواقع الويب الساكنة ( SSG )
74+
- أي واجهة أمامية غير بسيطة حيث يمكن تبرير استخدام عملية بناء المشروع لتوفير تجربة تطوير أفضل
7275

73-
- Single-Page Applications (SPA)
74-
- Static Site Generation (SSG)
75-
- Any non-trivial frontend where a build step can be justified for better development experience (DX).
76+
ومع ذلك ، ندرك أن هناك سيناريوهات يمكن أن تبدو فيها مكونات أحادية الملف و كأنها مُبالغة. هذا هو السبب في أنه لا يزال من الممكن استخدام Vue عبر JavaScript بشكل عادي بدون مرحلة بناء. إذا كنت تبحث فقط عن تحسين HTML إلى حد كبير من خلال التفاعلات الخفيفة ، فيُمكنك أيضا إلقاء نظرة على [petite-vue](https://github.com/vuejs/petite-vue) ، وهي نُسخة محدودة بحجم 6 كيلو بايت من Vue محسّنة من أجل تعزيز التدرج
77+
## كيف تعمل {#how-it-works}
7678

77-
That said, we do realize there are scenarios where SFCs can feel like overkill. This is why Vue can still be used via plain JavaScript without a build step. If you are just looking for enhancing largely static HTML with light interactions, you can also check out [petite-vue](https://github.com/vuejs/petite-vue), a 6 kB subset of Vue optimized for progressive enhancement.
78-
79-
## How It Works {#how-it-works}
80-
81-
Vue SFC is a framework-specific file format and must be pre-compiled by [@vue/compiler-sfc](https://github.com/vuejs/core/tree/main/packages/compiler-sfc) into standard JavaScript and CSS. A compiled SFC is a standard JavaScript (ES) module - which means with proper build setup you can import an SFC like a module:
79+
المٌكون أحادي الملف لـ vue هو تنسيق ملف خاص بإطار العمل و يجب تصريفه مُسبقا بواسطة [@vue/compiler-sfc](https://github.com/vuejs/core/tree/main/packages/compiler-sfc) إلى standard JavaScript و CSS. المُكون أحادي الملف (SFC) المُجمع هو standard JavaScript (ES) module (ES) - مما يعني أنه مع الإعداد المُناسب لمرحلة البناء، يُمكنك استيراد المكون أحادي الملف (SFC) كوحدة:
8280

8381
```js
8482
import MyComponent from './MyComponent.vue'
@@ -90,18 +88,18 @@ export default {
9088
}
9189
```
9290

93-
`<style>` tags inside SFCs are typically injected as native `<style>` tags during development to support hot updates. For production they can be extracted and merged into a single CSS file.
91+
عادة تُدرج وسوم `<style>` داخل المكونات أحادية الملف كوسوم `<style>` الأصلية أثناء التطوير لدعم التحديثات النشطة. أما في مرحلة الإنتاج يمكن استخراجها ودمجها في ملف CSS واحد.
9492

95-
You can play with SFCs and explore how they are compiled in the [Vue SFC Playground](https://sfc.vuejs.org/).
93+
يمكنك تجربة المكونات أحادية الملف واستكشاف كيفية تصريفها في [Vue SFC Playground](https://sfc.vuejs.org/).
9694

97-
In actual projects, we typically integrate the SFC compiler with a build tool such as [Vite](https://vitejs.dev/) or [Vue CLI](http://cli.vuejs.org/) (which is based on [webpack](https://webpack.js.org/)), and Vue provides official scaffolding tools to get you started with SFCs as fast as possible. Check out more details in the [SFC Tooling](/guide/scaling-up/tooling) section.
95+
في المشاريع الفعلية ، ندمج عادة مُترجم SFC مع أداة بناء مثل [Vite](https://vitejs.dev/) أو [Vue CLI](http://cli.vuejs.org/) (التي تعتمد على [webpack](https://webpack.js.org/)) ، وتوفر Vue أدوات تخطيط رسمية لبدء العمل مع ملفات SFC بأسرع ما يمكن. تحقق من المزيد من التفاصيل في قسم [أدوات SFC](/guide/scaling-up/tooling).
9896

99-
## What About Separation of Concerns? {#what-about-separation-of-concerns}
97+
## ماذا عن فصل نوع الشيفرات؟ {#what-about-separation-of-concerns}
10098

101-
Some users coming from a traditional web development background may have the concern that SFCs are mixing different concerns in the same place - which HTML/CSS/JS were supposed to separate!
99+
بعض المستخدمين القادمين من خلفية تطوير الويب التقليدية قد يكون لديهم القلق من أن المكونات أحادية الملف تخلط نوع شيفرات مختلفة في نفس المكان - والتي كان من المفترض أن تفصلها HTML / CSS / JS!
102100

103-
To answer this question, it is important for us to agree that **separation of concerns is not equal to the separation of file types**. The ultimate goal of engineering principles is to improve the maintainability of codebases. Separation of concerns, when applied dogmatically as separation of file types, does not help us reach that goal in the context of increasingly complex frontend applications.
101+
للإجابة على هذا السؤال، من المهم بالنسبة لنا الاتفاق على أن **فصل نوع الشيفرات لا يعني فصل أنواع الملفات.** الهدف النهائي من مبادئ الهندسة هو تحسين قابلية صيانة الشيفرة البرمجية. فصل نوع الشيفرات عند تطبيقه بشكل متعصب كفصل أنواع الملفات، لا يساعدنا في تحقيق هذا الهدف في سياق تطبيقات الواجهة الأمامية المعقدة بشكل متزايد.
104102

105-
In modern UI development, we have found that instead of dividing the codebase into three huge layers that interweave with one another, it makes much more sense to divide them into loosely-coupled components and compose them. Inside a component, its template, logic, and styles are inherently coupled, and colocating them actually makes the component more cohesive and maintainable.
103+
في تطوير واجهة المستخدم الحديثة ، وجدنا أنه بدلاً من تقسيم الشيفرة البرمجية إلى ثلاث طبقات ضخمة تتشابك مع بعضها البعض ، فمن المنطقي تقسيمها إلى مكونات غير مترابطة وتشكيلهم معا. داخل مُكون، فإن قالبه ومنطقه وأنماطه مقترنة بطبيعتها، ويجعل تجميعهم معًا المكون أكثر تماسكًا وقابلية للصيانة.
106104

107-
Note even if you don't like the idea of Single-File Components, you can still leverage its hot-reloading and pre-compilation features by separating your JavaScript and CSS into separate files using [Src Imports](/api/sfc-spec.html#src-imports).
105+
لاحظ أنه حتى لو لم تكن تحب فكرة المكونات أحادية الملف، يمكنك الاستفادة من ميزات إعادة التحميل السريع والتجميع المسبق عن طريق فصل JavaScript و CSS إلى ملفات منفصلة باستخدام [Src Imports](/api/sfc-spec.html#src-imports).

0 commit comments

Comments
 (0)