استخدم مساعدك المفضل للملخص واستخدم هذه الصفحة والموفر AI الذي تريده
تمت ترجمة محتوى هذه الصفحة باستخدام الذكاء الاصطناعي.
اعرض آخر نسخة المحتوى الأصلي باللغة الإنكليزيةIf you have an idea for improving this documentation, please feel free to contribute by submitting a pull request on GitHub.
GitHub link to the documentationCopy doc Markdown to clipboard
التعشيش / الإشارة إلى المحتوى الفرعي
كيف يعمل التعشيش
في Intlayer، يتم تحقيق التعشيش من خلال وظيفة nest، التي تتيح لك الإشارة إلى وإعادة استخدام المحتوى من قاموس آخر. بدلاً من تكرار المحتوى، يمكنك الإشارة إلى وحدة محتوى موجودة باستخدام مفتاحها.
إعداد التعشيش
To use nested content in a React component, leverage the useIntlayer hook from the react-intlayer package. This hook retrieves the correct content based on the specified key. Here's an example of how to use it:
نسخ الكود إلى الحافظة
import type { FC } from "react";
import { useIntlayer } from "react-intlayer";
const NestComponent: FC = () => {
const { fullNestedContent, partialNestedContent } = useIntlayer(
"key_of_my_second_dictionary"
);
return (
<div>
<p>Full Nested Content: {JSON.stringify(fullNestedContent)}</p>
<p>Partial Nested Value: {partialNestedContent}</p>
</div>
);
};
export default NestComponent;استخدام التعشيش مع React Intlayer
لاستخدام المحتوى المتعشش في مكون React، استخدم الخطاف useIntlayer من حزمة react-intlayer. يسترجع هذا الخطاف المحتوى الصحيح بناءً على المفتاح المحدد. إليك مثال على كيفية استخدامه:
نسخ الكود إلى الحافظة
import type { FC } from "react";
import { useIntlayer } from "react-intlayer";
const NestComponent: FC = () => {
const { fullNestedContent, partialNestedContent } = useIntlayer(
"key_of_my_second_dictionary"
);
return (
<div>
<p>
Full Nested Content: {JSON.stringify(fullNestedContent)}
{/* الإخراج: {"content": "content", "subContent": {"contentNumber": 0, "contentString": "string"}} */}
</p>
<p>
Partial Nested Value: {partialNestedContent}
{/* الإخراج: 0 */}
</p>
</div>
);
};
export default NestComponent;موارد إضافية
لمزيد من المعلومات التفصيلية حول التكوين والاستخدام، راجع الموارد التالية:
توفر هذه الموارد مزيدًا من الأفكار حول إعداد واستخدام Intlayer في بيئات مختلفة ومع أطر عمل متنوعة.