Shopify / mobile-buy-sdk-ios

Shopify’s Mobile Buy SDK makes it simple to sell physical products inside your mobile app. With a few lines of code, you can connect your app with the Shopify platform and let your users buy your products using Apple Pay or their credit card.
MIT License
452 stars 199 forks source link

Add support for translated fields #1050

Closed osamie closed 4 years ago

osamie commented 4 years ago

Fixes https://github.com/Shopify/mobile-buy-sdk-ios/issues/1049

Add support for translated fields

Storefront API translation header & translatable resources - https://help.shopify.com/en/api/guides/multi-language/translating-content-api#storefront-api-translation-header

How do merchants use this in their SDK? If your store supports multiple languages, Storefront API can return translated resource types and fields. Learn more about translating content.

Initializing the ios sdk to use a specific language

 let client: Graph.Client = 
    Graph.Client(
            shopDomain: "your-shop-name.myshopify.com", 
            apiKey: "your-storefront-access-token", 
            locale: Locale.current   // or Locale(identifier:"en-US") 
     )

When retrieving the language from the locale, foundation's Locale.identifier gives us a format which is not valid under the spec for use in the Accept-Language header. Hence we extend Locale to extract the language code and the identifier from the locale in the correct format for language tag.

Note: readme will be updated in a separate PR