Search code examples
react-nativereact-native-iap

How to get localised names from react-native-iap


We have localized iap products (very likely) correctly defined in Google Play and in App Store, but this code will not give us the localized titles of products. Should we configure something else? Or call some different method or add any options there? How do you localize your product names? Any tips are welcomed 🙏🏻.

  • react-native-iap: 11.0.4

code:

import {
  getProducts
} from 'react-native-iap'
...
const productIds =['productid12345']
const products = await getProducts({skus: productIds})
console.log(products)

response:

{
      "description":"Some description in english :(",
      "name":"English name :(",
      "oneTimePurchaseOfferDetails":{
         "formattedPrice":"100,00 Kč",
         "priceAmountMicros":"100000000",
         "priceCurrencyCode":"CZK"
      },
      "productId":"my.product.id.12345",
      "productType":"inapp",
      "title":"title only in English :("
   },

Definitions in stores: enter image description here enter image description here


Solution

  • Ok, so it works like this:

    • the language is taken regarding the App Store or Google Store language settings
    • if we want to change names by changing our in-app language settings, we have to add it to our translation files and match it by product.id
    • WARN: this will work, but you will lose the freedom of changing/adding products in the store and you have to do the new app release

    See this answer from react-native-iap library contributor: https://github.com/dooboolab-community/react-native-iap/issues/2458.