Skip to content

Commit

Permalink
Update example.
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardbeecroft committed May 13, 2023
1 parent 5b959bf commit f4b069f
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 12 deletions.
6 changes: 3 additions & 3 deletions Examples/Shared/QVKey.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import Foundation

/**
We always recommend declaring your keys centrally in their own file, instead of accessing by key inline.
You can then use something like: QuickVerse.shared.stringFor(key: QVKey.Onboarding_Demo_Body)
You can then use something like: QuickVerse.stringFor(key: QVKey.onboardingDemoTitle)
*/

class QVKey {
static let Onboarding_Demo_Body = "Onboarding.Demo.Body"
static let Onboarding_Demo_Title = "Onboarding.Demo.Title"
static let onboardingDemoTitle = "Onboarding.Demo.Title"
static let onboardingDemoBody = "Onboarding.Demo.Body"
}
4 changes: 2 additions & 2 deletions Examples/SwiftUI-Example/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ struct ContentView: View {
VStack() {
Spacer()
Spacer()
Text(viewModel.titleText)
Text(viewModel.titleText ?? "")
.font(Font(Fonts.lexendMedium(size: 20)))
.foregroundColor(Brand.Colors.darkGrey.color)
Text(viewModel.bodyText)
Text(viewModel.bodyText ?? "")
.font(Font(Fonts.lexendRegular(size: 14)))
.foregroundColor(Brand.Colors.lightGrey.color)
.multilineTextAlignment(.center)
Expand Down
11 changes: 7 additions & 4 deletions Examples/SwiftUI-Example/ContentViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ class ContentViewModel: ObservableObject {
private let demoLanguages = ["es", "it", "fr", "de", "en"]
private var demoLanguageIndex = 0

@Published var titleText = String()
@Published var bodyText = String()
@Published var titleText: String?
@Published var bodyText: String?
@Published var resultSourceText = String()

func getDeviceLanguageLocalizations() {
Expand Down Expand Up @@ -46,8 +46,11 @@ class ContentViewModel: ObservableObject {
}
private func updateLocalizedText() {
// Strongly Recommended - Use a centrally-declared keys file, such as QVKey - seen here
titleText = QuickVerse.stringFor(key: QVKey.Onboarding_Demo_Title, defaultValue: "Welcome to QuickVerse")
titleText = QuickVerse.stringFor(key: QVKey.onboardingDemoTitle)
// Alternatively, keys can be hardcoded "inline"
bodyText = QuickVerse.stringFor(key: QVKey.Onboarding_Demo_Body, defaultValue: "")
bodyText = QuickVerse.stringFor(key: QVKey.onboardingDemoBody)

// Optionally provide a default value
titleText = QuickVerse.stringFor(key: QVKey.onboardingDemoTitle, defaultValue: "Welcome to QuickVerse!")
}
}
5 changes: 4 additions & 1 deletion Examples/UIKit-Example/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,12 @@ private extension ViewController {
}
func updateLocalizedText() {
// Strongly Recommended - Use a centrally-declared keys file, such as QVKey - seen here
onboardingTitleLabel.text = QuickVerse.stringFor(key: QVKey.Onboarding_Demo_Title)
onboardingTitleLabel.text = QuickVerse.stringFor(key: QVKey.onboardingDemoTitle)
// Alternatively, keys can be hardcoded "inline"
onboardingBodyLabel.text = QuickVerse.stringFor(key: "Onboarding.Demo.Body")

// Optionally provide a default value
onboardingTitleLabel.text = QuickVerse.stringFor(key: QVKey.onboardingDemoTitle, defaultValue: "Welcome to QuickVerse!")
}
}

Expand Down
2 changes: 1 addition & 1 deletion QuickVerse.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |spec|
spec.name = "QuickVerse"
spec.version = "1.3.4"
spec.version = "1.4.0"
spec.summary = "Effortlessly integrate your quickverse.io localisations into your iOS app, for instant, over-the-air updates & more."
spec.description = <<-DESC
QuickVerse lets you translate your web and mobile apps with ease. Powered by instant, over-the-air updates, you can change your app copy anytime, anywhere.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ The library should have been added to the Swift Package Dependencies section, an

```
pod 'QuickVerse' // Always use the latest version
pod 'QuickVerse', '~> 1.3.4' // Or pin to a specific version
pod 'QuickVerse', '~> 1.4.0' // Or pin to a specific version
```
2. In a terminal window, navigate to the directory of your `Podfile`, and run `pod install --repo-update`

Expand Down

0 comments on commit f4b069f

Please sign in to comment.