🚀 DAY 5 OF LAUNCH WEEK: Introducing Socket Firewall Enterprise.Learn more →
Socket
Book a DemoInstallSign in
Socket

@skippay/capacitor-localization-settings

Package Overview
Dependencies
Maintainers
0
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@skippay/capacitor-localization-settings

Capacitor module to expose per-app language preferences API on iOS and Android.

latest
Source
npmnpm
Version
0.0.2
Version published
Maintainers
0
Created
Source

@skippay/capacitor-localization-settings

Capacitor module to expose per-app language preferences API on iOS and Android.

Capacitor v5

Install

npm install @skippay/capacitor-localization-settings
npx cap sync

API

  • getLanguage()
  • setLanguage(...)

getLanguage()

getLanguage() => Promise<{ value: string; }>

Returns: Promise<{ value: string; }>

setLanguage(...)

setLanguage(options: { value: string; }) => Promise<{ value: string; }>
ParamType
options{ value: string; }

Returns: Promise<{ value: string; }>

Define supported languages

To get started, you'll need to define the languages that your app supports.

iOS

Open your project in XCode, in Project Navigator select project, go to Info tab, and under Localizations section add languages you want to support.

XCode screenshot

Next, you need to create a Localization.strings file.

XCode screenshot

Select newly created file and on the right side of the screen, under Localizations selection press Localize. Confirm the popup.

XCode screenshot

Lastly, you need to select all elements in the section form previous step.

Android

Create new file in android/app/src/main/res/xml directory named locales_config.xml. and define supported languages:

<?xml version="1.0" encoding="utf-8"?>
<locale-config xmlns:android="http://schemas.android.com/apk/res/android">
  <locale android:name="en"/>
  <locale android:name="pl"/>
  <locale android:name="fr"/>
</locale-config>

Then, open android/app/src/main/AndroidManifest.xml and add following line to the Application tag:

<application
        android:name=".MainApplication"
        android:localeConfig="@xml/locales_config" <!-- this line -->
>

Inspiration

This plugin is heavily inspired by react-native-localization-settings plugin.

Keywords

capacitor

FAQs

Package last updated on 22 Aug 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts