اذهب إلى المحتوى
  • 0

ERROR ReferenceError: Can't find variable: Intl مشكلة في React Native

أحمد عبد الله2

السؤال

ما حل هذا الخطأ 

 ERROR  ReferenceError: Can't find variable: Intl

 

 

import React from 'react';
import {View, Text, I18nManager} from 'react-native';

import i18n from "i18next"
import {initReactI18next} from "react-i18next"

import ar from './langs/ar';
import en from './langs/en';
import Screen from './langs/Screen';
const {isRTL, forceRTL, allowRTL} = I18nManager;

i18n.use(initReactI18next).init({
  resources: {
    ar: {
      translation: ar,
    },
    en: {
      translation: en,
    },
  },
  lng: isRTL ? 'ar' : 'en',
  fallbackLng: isRTL ? 'ar' : 'en',
  interpolation: {
    escapeValue: false,
  },
});
export default function App() {
  return (
    <View style={{flex:1}}>
      {/* <Screen /> */}
    </View>
  );
}

 

تم التعديل في بواسطة Wael Aljamal
توضيح السؤال
رابط هذا التعليق
شارك على الشبكات الإجتماعية

Recommended Posts

  • 0

حاول تثبيت المكتبة، ربما هي اعتمادية

npm install intl

 

ثم عليك تضمينها،

import "intl";
import { Platform } from "react-native";
import "intl/locale-data/jsonp/en";

if (Platform.OS === "android") {
    // See https://github.com/expo/expo/issues/6536 for this issue.
    if (typeof (Intl as any).__disableRegExpRestore === "function") {
        (Intl as any).__disableRegExpRestore();
    }
}

تأكد من وضع هذه الشيفرة في أول الصفحة

إن كنت تستخدم ريأكت نيتف، فربما تحتاج لثبيت react-intl

 "jsc-android": "^241213.1.0",
    "react": "16.9.0",
    "react-intl": "^4.3.1",
    "react-native": "^0.62.2",

قد تختلف إصدارات هذه المكتبات، حاول تثبيتهم بطريقة عادية، باسم المكتبة

رابط هذا التعليق
شارك على الشبكات الإجتماعية

  • 0

يجب عليك تثبيت react-intl

npm i -S react react-intl

ثم يجب  عليك استخدامه في مشروعك بهذه الطريقة

import React from 'react';
import {View, Text, I18nManager} from 'react-native';

import {IntlProvider} from 'react-intl'


import i18n from "i18next"
import {initReactI18next} from "react-i18next"

import ar from './langs/ar';
import en from './langs/en';
import Screen from './langs/Screen';
const {isRTL, forceRTL, allowRTL} = I18nManager;

i18n.use(initReactI18next).init({
  resources: {
    ar: {
      translation: ar,
    },
    en: {
      translation: en,
    },
  },
  lng: isRTL ? 'ar' : 'en',
  fallbackLng: isRTL ? 'ar' : 'en',
  interpolation: {
    escapeValue: false,
  },
});
export default function App() {
  return (
        <IntlProvider>

    <View style={{flex:1}}>
      {/* <Screen /> */}
    </View>
        </IntlProvider>

  );
}

 

رابط هذا التعليق
شارك على الشبكات الإجتماعية

انضم إلى النقاش

يمكنك أن تنشر الآن وتسجل لاحقًا. إذا كان لديك حساب، فسجل الدخول الآن لتنشر باسم حسابك.

زائر
أجب على هذا السؤال...

×   لقد أضفت محتوى بخط أو تنسيق مختلف.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   جرى استعادة المحتوى السابق..   امسح المحرر

×   You cannot paste images directly. Upload or insert images from URL.

  • إعلانات

  • تابعنا على



×
×
  • أضف...