J3.x:تطوير مكون MVC/اضافة ادارة لغة
From Joomla! Documentation
< J3.x:Developing an MVC Component
This page is tagged because it NEEDS REVIEW. You can help the Joomla! Documentation Wiki by contributing to it.
More pages that need help similar to this one are here. NOTE-If you feel the need is satistified, please remove this notice.
المقالات في هذه السلسلة
اضافة نمط قائمة الى جزء الموقع
اضافة موديل الى جزء الموقع
اضافة طلب متحول في نوع القائمة
استخدام قاعدة البيانات
واجهة خلفية بسيطة
اضافة ادارة لغة
اضافة أفعال في الواجهة الخلفية
اضافة ديكور الى الواجهة الخلفية
اضافة التحقيقات
اضافة فئات
اضافة اعداد
اضافة ملف سكريبت لتثبيت/فك تثبيت/تحديث
Adding a Frontend Form
استخدام ميزات تصفية اللغة
- Adding a Modal
- Adding Associations
- Adding Checkout
- Adding Ordering
- Adding Levels
- Adding Versioning
- Adding Tags
- Adding Access
- Adding a Batch Process
- Adding Cache
- Adding a Feed
اضافة مخدم تحديث
هذه سلسلة من عدة مقالات من الدروس حول كيفية تطوير موديل-عرض-موجه مكون لنسخة Joomla! .
تبدأ مع مقدمة, وتستعرض المقالات في هذه السلسلة باستخدام زر التنقل في الأسفل أو الصندوق الأيمن ("المقالات في هذه السلسلة").
مقدمة
هذا الدرس هو جزء من درس تطوير مكون MVC لـ Joomla! 3.2 . نشجعك على قراءة الجزء السابق من الدرس قبل قراءة هذا الدرس.
You can watch a video associated with this step in the tutorial at Step 8, Adding Language Management.
Joomla! 3.2 ادارة اللغات للمكون في أربع حالات مختلفة:
- إظهار المكون في الموقع العام
- ادارة المكون في الواجهة الخلفية
"ادارة القوائم في الواجهة الخلفية
- تثبيت المكون
يستخدم Joomla! 3.2 مكانين مختلفين لفهرس اللغات:
- واحد في administrator/language أو language
- واحد في فهرس المكون (administrator/components/*component*/language أو components/*component*/language)
وهو يعتمد على كيفية تثبيت المكون.
اضافة ترجمة لغة في الموقع العام
ياستخدام مدير الملف المفضل لديك والمحرر، ضع ملف site/language/en-GB/en-GB.com_helloworld.ini. وهذا الملف سيحتوي الترجمة للجزء العام. ولهذه اللحظة الملف فارغ.
site/language/en-GB/en-GB.com_helloworld.ini
ولهذه اللحظة، لاتوجد سلاسل ترجمة في الملف.
اضافة ترجمة لغة عند ادارة المكون
ياستخدام مدير الملف المفضل لديك والمحرر، ضع ملف admin/language/en-GB/en-GB.com_helloworld.ini. وهذا الملف سيحتوي الترجمة للجزء الواجهة الخلفية .
admin/language/en-GB/en-GB.com_helloworld.ini
; Joomla! Project
; Copyright (C) 2005 - 2018 Open Source Matters. All rights reserved.
; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php
; Note : All ini files need to be saved as UTF-8
COM_HELLOWORLD_NUM="#"
COM_HELLOWORLD_PUBLISHED="Published"
COM_HELLOWORLD_HELLOWORLDS_NAME="Name"
COM_HELLOWORLD_ID="Id"
COM_HELLOWORLD_HELLOWORLD_FIELD_GREETING_DESC="This message will be displayed"
COM_HELLOWORLD_HELLOWORLD_FIELD_GREETING_LABEL="Message"
COM_HELLOWORLD_HELLOWORLD_HEADING_GREETING="Greeting"
COM_HELLOWORLD_HELLOWORLD_HEADING_ID="Id"
اضافة ترجمة لغة عند ادارة القوائم في الواجهة الخلفية
ياستخدام مدير الملف المفضل لديك والمحرر، ضع ملف admin/language/en-GB/en-GB.com_helloworld.sys.ini. وهذا الملف سيحتوي الترجمة لجزء الواجهة الخلفية .
admin/language/en-GB/en-GB.com_helloworld.sys.ini
; Joomla! Project
; Copyright (C) 2005 - 2015 Open Source Matters. All rights reserved.
; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php
; Note : All ini files need to be saved as UTF-8
COM_HELLOWORLD="Hello World!"
COM_HELLOWORLD_DESCRIPTION="This is the Hello World description"
COM_HELLOWORLD_HELLOWORLD_VIEW_DEFAULT_TITLE="Hello World"
COM_HELLOWORLD_HELLOWORLD_VIEW_DEFAULT_DESC="This view displays a selected message"
COM_HELLOWORLD_MENU="Hello World!"
خيارات مكان ملف اللغة
بدءا من النسخة 1.7 هنالك طريقتين لتثبيت ملفات اللغة للملحق. واحد ممكن أن يستخدم واحد أو الآخر أو اجتماع الاثنين .
طريقة 1.5 سيثبت الملفات في فهارس اللغة الأساسية (ROOT/administrator/language/ and ROOT/language/). منذ النسخة 1.6، تم تضمين الملفات في فهرس "اللغة" مثبتة في الجذر الخاص بالملحق.
ولذلك الملحق يمكن أن يتضمن فهرس لغة مع .sys.ini مختلف عن ذلك المثبت في فهرس اللغة الأساسي في جوملا. (وهذا الأخير ليس متضمن في فهرس اللغة ذاك ولكن في الجذر أو أي فهرس غير مثبت.)
وهذا يدعنا نظهر وصفين مختلفين: واحد من sys.ini في فهرس "اللغة" يستخدم كرسالة تظهر عند انتهاء التثبيت، والأخرى (من .ini) تستخدم من التشغيل "العادي"،هذا هو، عندما يتم تحرير ملحق في الجهة الخلفية. هذا يمكن أن يكون مفيدا للغاية عندما يستخدم التثبيت أيضا بعض النصوص ويتطلب قيمة مختلفة للوصف.
الملف sys.ini يستخدم أيضا لترجمة اسم الملحقات في بعض ادارات الواجهة الخلفية وليؤمن ترجمة القائمة للمكون.
ولذلك، تم اضافة xml منذ 1.6:
<files>
<[...]
<folder>language</folder> // This folder HAS to include the right subfolders, i.e. language/en-GB/ ... language/fr-FR/
<filename>whatever</filename>
[...]
</files>
<administration>
<files folder="admin">
<[...]
<folder>language</folder>
<filename>whatever</filename>
<[...]
</files>
</administration>
و/أو بعدها (طريقة 1.5):
<languages folder="joomlacorelanguagefolders"> // If using another language folder for cleanliness. (Any folder name will fit.)
<language tag="en-GB">en-GB/en-GB.whatever.ini</language> // or
<language tag="en-GB">en-GB.whatever.ini</language> if no tagged subfolder
<language tag="en-GB">en-GB/en-GB.whatever.sys.ini</language> // or
<language tag="en-GB">en-GB.whatever.sys.ini</language> if no tagged subfolder
</languages>
أو ببساطة في الجذر:
<languages>
<language tag="en-GB">en-GB.whatever.ini</language>
<language tag="en-GB">en-GB.whatever.sys.ini</language>
</languages>
بستخدم ملف اللعة بواسطة نصوص التثبيت خلال تثبيت المكون ("التثبيت الأول"،وليس التحديث) تمتثل لقواعد محددة موصوفة في المقال، مواصفات ملفات اللغة. خلال التثبيت الأول، فقط ملف اللغة يتضمن في فهرس المكون (/administrator/components/com_helloworld/language)
is used when present. If this file is only provided in the CORE language folder (/administrator/language)
, يستخدم عند التواجد. وإذا كان الملف فقط مزود في فهرس اللغة الأساسي (/administrator/language)
, لا تحدث ترجمة. وهذا ينطبق أيضا على المفاتيح المستخدمة في ملف البيان.
عند تحديث أو فك تثبيت الملحق (ليس تثبيت)، يكون ملف sys.ini موجود في فهرس جذر اللغة للملحق والذي سيظهر نتيجة التثبيت من وصف key/value. ولذلك، إذا كان موجود، الـ sys.ini كما .ini مثبت في فهرس اللغة الأساسي سيكون له أولوية فوق الملفات الموجودة في فهرس جذر اللغة للملحق.
"ميزة واحدة لتثبيت الملفات في فهرس "اللغة" للملحق وهي أنها " لاتمس هذه الملفات عند التحديث" حزمة اللغة.
والميزة الأخرى هي أن هذا الفهرس ممكن أن يتضمن عدة لغات (en-GB always, fr-FR, it-IT, etc.) لا تتطلب من المستخدم تثبيت حزمة اللغة المطابقة. هذا هو مفيد لأنها متوفرة إذا، في وقت لاحق، قام مستخدم بتثبيت الحزمة المقابلة.حزم المكون
محتوياات فهرس الشفرة الخاص بك
- helloworld.xml
- site/helloworld.php
- site/index.html
- site/controller.php
- site/views/index.html
- site/views/helloworld/index.html
- site/views/helloworld/view.html.php
- site/views/helloworld/tmpl/index.html
- site/views/helloworld/tmpl/default.xml
- site/views/helloworld/tmpl/default.php
- site/models/index.html
- site/models/helloworld.php
- site/language/index.html
- site/language/en-GB/index.html
- site/language/en-GB/en-GB.com_helloworld.ini
- admin/index.html
- admin/helloworld.php
- admin/controller.php
- admin/sql/index.html
- admin/sql/install.mysql.utf8.sql
- admin/sql/uninstall.mysql.utf8.sql
- admin/sql/updates/index.html
- admin/sql/updates/mysql/index.html
- admin/sql/updates/mysql/0.0.1.sql
- admin/sql/updates/mysql/0.0.6.sql
- admin/models/index.html
- admin/models/fields/index.html
- admin/models/fields/helloworld.php
- admin/models/helloworlds.php
- admin/views/index.html
- admin/views/helloworlds/index.html
- admin/views/helloworlds/view.html.php
- admin/views/helloworlds/tmpl/index.html
- admin/views/helloworlds/tmpl/default.php
- admin/tables/index.html
- admin/tables/helloworld.php
- admin/language/index.html
- admin/language/en-GB/en-GB.com_helloworld.ini
- admin/language/en-GB/en-GB.com_helloworld.sys.ini
- admin/language/en-GB/index.html
انشئ ملف مضغوط عن هذا الفهرس أو حمل مباشرة من archive وثبته باستخدام مدير الملحقات في Joomla!. بامكانك اضافة عنصر قائمة لهذا المكون باستخدام مدير القائمة في الخلفية.
helloworld.xml
<?xml version="1.0" encoding="utf-8"?>
<extension type="component" version="3.0" method="upgrade">
<name>COM_HELLOWORLD</name>
<!-- The following elements are optional and free of formatting constraints -->
<creationDate>January 2018</creationDate>
<author>John Doe</author>
<authorEmail>john.doe@example.org</authorEmail>
<authorUrl>http://www.example.org</authorUrl>
<copyright>Copyright Info</copyright>
<license>License Info</license>
<!-- The version string is recorded in the components table -->
<version>0.0.8</version>
<!-- The description is optional and defaults to the name -->
<description>COM_HELLOWORLD_DESCRIPTION</description>
<install> <!-- Runs on install -->
<sql>
<file driver="mysql" charset="utf8">sql/install.mysql.utf8.sql</file>
</sql>
</install>
<uninstall> <!-- Runs on uninstall -->
<sql>
<file driver="mysql" charset="utf8">sql/uninstall.mysql.utf8.sql</file>
</sql>
</uninstall>
<update> <!-- Runs on update; New since J2.5 -->
<schemas>
<schemapath type="mysql">sql/updates/mysql</schemapath>
</schemas>
</update>
<!-- Site Main File Copy Section -->
<!-- Note the folder attribute: This attribute describes the folder
to copy FROM in the package to install therefore files copied
in this section are copied from /site/ in the package -->
<files folder="site">
<filename>index.html</filename>
<filename>helloworld.php</filename>
<filename>controller.php</filename>
<folder>views</folder>
<folder>models</folder>
</files>
<languages folder="site/language">
<language tag="en-GB">en-GB/en-GB.com_helloworld.ini</language>
</languages>
<administration>
<!-- Administration Menu Section -->
<menu link='index.php?option=com_helloworld'>COM_HELLOWORLD_MENU</menu>
<!-- Administration Main File Copy Section -->
<!-- Note the folder attribute: This attribute describes the folder
to copy FROM in the package to install therefore files copied
in this section are copied from /admin/ in the package -->
<files folder="admin">
<!-- Admin Main File Copy Section -->
<filename>index.html</filename>
<filename>helloworld.php</filename>
<filename>controller.php</filename>
<!-- SQL files section -->
<folder>sql</folder>
<!-- tables files section -->
<folder>tables</folder>
<!-- models files section -->
<folder>models</folder>
<!-- views files section -->
<folder>views</folder>
</files>
<languages folder="admin/language">
<language tag="en-GB">en-GB/en-GB.com_helloworld.ini</language>
<language tag="en-GB">en-GB/en-GB.com_helloworld.sys.ini</language>
</languages>
</administration>
</extension>
في هذا الملف helloworld.xml، اللغات مثبتة في:
- administrator/language لجزء المدير (انظر الى وسم اللغة في xml).
- components/com_helloworld/language لجزء الموقع (there are no xmلايوجد وسم لغات xml في قسم الموقع لملف وصف xml، ولكن فهرس اللغة متضمن).
الرجاء انشاء طلب سحب أو مشكلة على https://github.com/joomla/Joomla-3.2-Hello-World-Component لأي اختلافات في الكود أو أي تعديل في شفرة المصدر على هذه الصفحة.