about summary refs log tree commit diff
path: root/modules/expo-bluesky-translate/src/ExpoBlueskyTranslateView.ios.tsx
blob: daddfa02866e42d74cc04d7ad0f61ade05494c29 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import React from 'react'
import {Platform} from 'react-native'
import {requireNativeModule, requireNativeViewManager} from 'expo-modules-core'

import {ExpoBlueskyTranslateModule} from './ExpoBlueskyTranslate.types'

export const NativeTranslationModule =
  requireNativeModule<ExpoBlueskyTranslateModule>('ExpoBlueskyTranslate')

const NativeView: React.ComponentType = requireNativeViewManager(
  'ExpoBlueskyTranslate',
)

export function NativeTranslationView() {
  return <NativeView />
}

export const isAvailable = Number(Platform.Version) >= 17.4

// https://en.wikipedia.org/wiki/Translate_(Apple)#Languages
const SUPPORTED_LANGUAGES = [
  'ar',
  'zh',
  'zh',
  'nl',
  'en',
  'en',
  'fr',
  'de',
  'id',
  'it',
  'ja',
  'ko',
  'pl',
  'pt',
  'ru',
  'es',
  'th',
  'tr',
  'uk',
  'vi',
]

export function isLanguageSupported(lang?: string) {
  // If the language is not provided, we assume it is supported
  if (!lang) return true
  return SUPPORTED_LANGUAGES.includes(lang)
}