Skip to content

Commit

Permalink
Trying to add localized duration strings
Browse files Browse the repository at this point in the history
  • Loading branch information
mcallisto committed Jan 22, 2021
1 parent 4d9507c commit 38dcd39
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 2 deletions.
5 changes: 4 additions & 1 deletion react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,16 @@
"expo-av": "~8.2.1",
"expo-font": "~8.2.1",
"expo-constants": "~9.1.1",
"expo-localization": "~8.2.1",
"expo-web-browser": "~8.2.1",
"react": "16.11.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-38.0.2.tar.gz",
"react-router-native": "5.1.2",
"react-native-webview": "10.8.2",
"typescript": "~3.9.5",
"url": "~0.11.0"
"url": "~0.11.0",
"moment": "2.29.1",
"dayjs": "1.10.4"
},
"devDependencies": {
"@babel/core": "^7.9.0",
Expand Down
8 changes: 7 additions & 1 deletion react-native/src/main/scala/hello/world/App.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ import scala.scalajs.js.|
object Home extends RoutePath("/", "Home")
object Antd extends RoutePath("/antd", "Antd")
object PlayAudio extends RoutePath("/audio", "PlayAudio")
object Duration extends RoutePath("/duration", "Duration")
object Webview extends RoutePath("/webview", "Webview")
object ReactRouter extends RoutePath("/react_router", "React Router")

val allOrdered: List[RoutePath] = List(Home, Antd, PlayAudio, Webview, ReactRouter)
val allOrdered: List[RoutePath] = List(Home, Antd, PlayAudio, Webview, Duration, ReactRouter)
}

type Props = Unit
Expand Down Expand Up @@ -65,6 +66,11 @@ import scala.scalajs.js.|
.setPath(RoutePath.Webview.path)
.setRender(_ => Webview())
),
Route(
RouteProps()
.setPath(RoutePath.Duration.path)
.setRender(_ => Duration())
),
Route(
RouteProps()
.setPath(RoutePath.ReactRouter.path)
Expand Down
38 changes: 38 additions & 0 deletions react-native/src/main/scala/hello/world/Duration.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package hello.world

import slinky.core.FunctionalComponent
import slinky.core.annotations.react
import slinky.core.facade.Hooks.useState
import slinky.native.{Text, View}
import typings.antDesignReactNative.components._
import typings.antDesignReactNative.{antDesignReactNativeStrings => antdStrings}
import typings.expoLocalization.mod.locale
import typings.moment.mod.{^ => moment}
import typings.dayjs.mod.{^ => dayjs}
import java.time.Instant
import scala.scalajs.js

@react object Duration {

type Props = Unit

val component = FunctionalComponent[Props] { _ =>

// should set day.js locale
dayjs().locale("es")

View(
Text("Duration"),
WhiteSpace().size(antdStrings.md),
Text(s"Expo current locale: $locale"),
WhiteSpace().size(antdStrings.md),
Text(s"moment.js current locale: ${moment().locale()}"),
Text(s"moment.js duration en_US: ${moment().locale("en_US").fromNow()}"),
Text(s"moment.js duration es_ES: ${moment().locale("es_ES").fromNow()}"),
Text(s"moment.js duration fr_FR: ${moment().locale("fr_FR").fromNow()}"),
Text(s"moment.js duration it_IT: ${moment().locale("it_IT").fromNow()}"),
WhiteSpace().size(antdStrings.md),
Text(s"day.js current locale: ${dayjs().locale()}")
)
}
}
22 changes: 22 additions & 0 deletions react-native/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2212,6 +2212,11 @@ csstype@^3.0.2:
resolved "https://registry.yarnpkg.com/csstype/-/csstype-3.0.3.tgz#2b410bbeba38ba9633353aff34b05d9755d065f8"
integrity sha512-jPl+wbWPOWJ7SXsWyqGRk3lGecbar0Cb0OvZF/r/ZU011R4YqiRehgkQ9p4eQfo9DSDLqLL3wHwfxeJiuIsNag==

dayjs@1.10.4:
version "1.10.4"
resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.10.4.tgz#8e544a9b8683f61783f570980a8a80eaf54ab1e2"
integrity sha512-RI/Hh4kqRc1UKLOAf/T5zdMMX5DQIlDxwUe3wSyMMnEbGunnpENCdbUgM+dW7kXidZqCttBrmw7BhN4TMddkCw==

dayjs@^1.8.15:
version "1.8.29"
resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.8.29.tgz#5d23e341de6bfbd206c01136d2fb0f01877820f5"
Expand Down Expand Up @@ -2605,6 +2610,13 @@ expo-linking@~1.0.3:
qs "^6.5.0"
url-parse "^1.4.4"

expo-localization@~8.2.1:
version "8.2.1"
resolved "https://registry.yarnpkg.com/expo-localization/-/expo-localization-8.2.1.tgz#99d422670d9e4261268f1feed9c4d228183a745b"
integrity sha512-T2S1J6L0VaKdiO10kQk690GGMdO990zKXKGvdw5D8UEfoFomXh0W2CTtfqN2HCkkpc7iqvn7MYaKN0yJxu+jJQ==
dependencies:
rtl-detect "^1.0.2"

expo-location@~8.2.1:
version "8.2.1"
resolved "https://registry.yarnpkg.com/expo-location/-/expo-location-8.2.1.tgz#5ea6bfd3d211939117416da151f1384caa15e0db"
Expand Down Expand Up @@ -4141,6 +4153,11 @@ mkdirp@^0.5.1:
dependencies:
minimist "^1.2.5"

moment@2.29.1:
version "2.29.1"
resolved "https://registry.yarnpkg.com/moment/-/moment-2.29.1.tgz#b2be769fa31940be9eeea6469c075e35006fa3d3"
integrity sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ==

ms@2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8"
Expand Down Expand Up @@ -4992,6 +5009,11 @@ rsvp@^4.8.4:
resolved "https://registry.yarnpkg.com/rsvp/-/rsvp-4.8.5.tgz#c8f155311d167f68f21e168df71ec5b083113734"
integrity sha512-nfMOlASu9OnRJo1mbEk2cz0D56a1MBNrJ7orjRZQG10XDyuvwksKbuXNp6qa+kbn839HwjwhBzhFmdsaEAfauA==

rtl-detect@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/rtl-detect/-/rtl-detect-1.0.2.tgz#8eca316f5c6563d54df4e406171dd7819adda67f"
integrity sha512-5X1422hvphzg2a/bo4tIDbjFjbJUOaPZwqE6dnyyxqwFqfR+tBcvfqapJr0o0VygATVCGKiODEewhZtKF+90AA==

run-async@^2.2.0:
version "2.4.1"
resolved "https://registry.yarnpkg.com/run-async/-/run-async-2.4.1.tgz#8440eccf99ea3e70bd409d49aab88e10c189a455"
Expand Down

0 comments on commit 38dcd39

Please sign in to comment.