How can I localize PWA camera strings in Ionic?

Viewed 111

I'm using the Capacitor camera plugin to get a user's photos.

The code is here:

const { Camera } = Plugins;
Camera.getPhoto({
      quality: 90,
      allowEditing: false,
      resultType: CameraResultType.Uri,
      source: CameraSource.Prompt,
      saveToGallery: false,
    })....

How can I translate Camera strings like below image? (No camera found, Choose image.)

Enter image description here

1 Answers

Ionic PWA elements uses Stencil and the message for no camera found is the input to the web element that exists in the ionic-team/pwa-elements repository.

If you can get the reference to the Ionic's PWA-element, just give it the custom input of noDevicesText and it will be as you want. I know it's a hack, but there isn’t any direct input given for this use case. You can also create a feature request to the camera plugin repository.

See camera.tsx.

E.g.:

// pwa-camera is the PWA camera component
let cameraElement = document.querySelector('pwa-camera');
if (cameraElement) {
  cameraElement.noDevicesText = this.someService.translate(message);
}
Related