简体   繁体   中英

How to use Expo Camera in react native?

Expo Camera is working in my code.

Current Code

const { status } = await Permissions.askAsync(Permissions.CAMERA);
if (status === 'granted') {
  const result = await ImagePicker.launchCameraAsync({
    allowsEditing: true,
    mediaTypes: ImagePicker.MediaTypeOptions.Images,
  });
}

if status === 'granted', camera opens.

What I want to do

I wanna change text 'Cancel' to Japanese on the bottom.

Is there any way to set locale?

I would appreciate it if you could give me any advice.

相机

The dialog block should be native and language should becomes your phone's setting language, maybe you could try to change your phone to Japanese local and restart the app.

If you want to customer the dialog, you could detect and using Alert.alert to show what you want to show, but request may be native to ask again.

Something like this I used before:

Alert.alert(
  I18n.t('Permission_requireTitle'),
  I18n.t('Permission_camera'),
  [
    {
      text: I18n.t('Permission_btn1'),
      onPress: () => {
        console.log("Permission denied");
        Actions.pop();
      },
      style: "cancel"
    },
    {
      text: I18n.t('Permission_btn3'),
      onPress: () => {        
        AndroidOpenSettings.appDetailsSettings();
      }
    }
  ],
  { cancelable: false }
);

Or maybe it have language setting in your permission package you could try to find.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM