Skip to content

Commit

Permalink
translate app
Browse files Browse the repository at this point in the history
  • Loading branch information
RennanRbs committed Nov 25, 2019
1 parent 52c3b9f commit 23d782f
Show file tree
Hide file tree
Showing 12 changed files with 98 additions and 16 deletions.
21 changes: 20 additions & 1 deletion MyBujo2.0/Business Rules/Models/DayExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,22 @@
import Foundation
import CoreData
import UIKit

let happyT = NSLocalizedString("Happy",
comment: "Happy")
let sadT = NSLocalizedString("Sad",
comment: "Sad")
let angryT = NSLocalizedString("Angry",
comment: "Angry")
let anxiouaT = NSLocalizedString("Anxious",
comment: "Anxious")
let indiferentT = NSLocalizedString("Indiferent",
comment: "Indiferent")
let gratefulT = NSLocalizedString("Grateful",
comment: "Grateful")
let surprisedT = NSLocalizedString("Surprised",
comment: "Surprised")
let tiredT = NSLocalizedString("Tired",
comment: "Tired")
enum Feeling: String {
case happy = "Happy"
case sad = "Sad"
Expand All @@ -20,6 +35,10 @@ enum Feeling: String {
case surprised = "Surprised"
case tired = "Tired"

func localizedString() -> String {
return NSLocalizedString(self.rawValue, comment: "")
}

var color: UIColor {
switch self {
case .happy:
Expand Down
4 changes: 2 additions & 2 deletions MyBujo2.0/Business Rules/Utils/HeaderViewFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ struct HeaderViewFactory {
}()
var goalsLabel: UILabel = {
let label = UILabel()
label.text = NSLocalizedString("Metas", comment: "Goals")
label.text = NSLocalizedString("Goals", comment: "Goals")
return label
}()
var mediaLabel: UILabel = {
let label = UILabel()
label.text = NSLocalizedString("Mídias", comment: "Media")
label.text = NSLocalizedString("Media", comment: "Media")
return label
}()
var tableView: UITableView!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ class DrawingViewController: MediaViewController {
setupToolPicker()
setupNavigationBar()
self.navigationController?.interactivePopGestureRecognizer?.isEnabled = false
self.title = "Drawing"
localizableLabel()
}
func localizableLabel() {
let formatStringGoalLabel = NSLocalizedString("Drawing",
comment: "Drawing")
self.title = String.localizedStringWithFormat(formatStringGoalLabel)
}

override func viewDidDisappear(_ animated: Bool) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class FeelingCollectionViewCell: UICollectionViewCell, ViewCode {

func setupCell(feeling: Feeling) {
self.feeling = feeling
feelingTitle.text = feeling.rawValue
feelingTitle.text = self.feeling.localizedString()
feelingCircle.backgroundColor = feeling.color
didSelect()
}
Expand Down
2 changes: 1 addition & 1 deletion MyBujo2.0/Use Cases/Daily/Feelings/FeelingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class FeelingsView: UIView, ViewCode {

var selectedFeeling: Feeling?

let feelingsCardTitle = UILabel(text: "Como você está se sentindo hoje?", font: .title, textColor: .titleColor)
let feelingsCardTitle = UILabel(text: "How are you feeling today?", font: .title, textColor: .titleColor)

lazy var collectionView: UICollectionView = {
let flowLayout = UICollectionViewFlowLayout()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ extension GoalsTableViewCell: UITableViewDelegate, UITableViewDataSource {

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
guard let cell = tableView.dequeueReusableCell(withIdentifier: GoalTableViewCell.reuseIdentifier, for: indexPath) as? GoalTableViewCell else { return GoalTableViewCell() }
goals.count == 0 ? cell.goalDescription.text = "Add one goal here." : cell.setupCell(goal: goals[indexPath.row])
let addGoal = NSLocalizedString("Add one goal here.",
comment: "Add one goal here.")
goals.count == 0 ? cell.goalDescription.text = addGoal : cell.setupCell(goal: goals[indexPath.row])
return cell
}

Expand Down
11 changes: 10 additions & 1 deletion MyBujo2.0/Use Cases/Daily/Media/Views/MediaTableViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,16 @@ class MediaTableViewCell: UITableViewCell {

// MARK: Properties
let iconNames = [(sf: "text.justifyleft", normal: "notes"), (sf: "pencil.and.outline", normal: "pencil"), (sf: "mic", normal: "mic"), (sf: "camera", normal: "camera"), (sf: "video", normal: "videoCamera")]
let iconName = ["Notas","Desenho","Áudio","Foto"]
let noteT = NSLocalizedString("Note",
comment: "Note")
let drawingT = NSLocalizedString("Drawing",
comment: "Drawing")
let recordt = NSLocalizedString("Record",
comment: "Record")
let capturest = NSLocalizedString("Captures",
comment: "Captures")

lazy var iconName = [self.noteT, self.drawingT, self.recordt, self.capturest]
static let reuseIdentifier = "MediaTableCell"
weak var delegate: MediaCollectionViewDelegate?

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,16 @@ class NotesViewController: MediaViewController, ViewCode {
}

func configureNavigationBar() {
self.title = "Notes"
localizableLabel()
let eraseBarButtonItem = UIBarButtonItem(barButtonSystemItem: .trash, target: self, action: #selector(shouldCleanTextView))
navigationItem.setRightBarButton(eraseBarButtonItem, animated: true)
}

func localizableLabel() {
let formatStringGoalLabel = NSLocalizedString("Note",
comment: "Note")
self.title = String.localizedStringWithFormat(formatStringGoalLabel)
}

@objc func shouldCleanTextView() {
noteTextView.text = String()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ import Photos
class CapturesViewController: GalleryViewController {

var canEdit: Bool = false

lazy var editGalleryBarButtomItem = UIBarButtonItem(title: "Editar", style: .plain, target: self, action: #selector(shouldEnableEditGallery))
let formatStringEdit = NSLocalizedString("Edit",
comment: "Edit")
lazy var editGalleryBarButtomItem = UIBarButtonItem(title: self.formatStringEdit, style: .plain, target: self, action: #selector(shouldEnableEditGallery))
weak var delegateTarget: MediaCollectionViewTargetDelegate?

override func viewWillAppear(_ animated: Bool) {
self.title = "Fotos"
localizableLabel()
let addPhotoBarButtomItem = UIBarButtonItem(barButtonSystemItem: .add, target: self, action: #selector(presentImagePickerController))
navigationItem.setRightBarButtonItems([addPhotoBarButtomItem, editGalleryBarButtomItem], animated: true)
}
Expand All @@ -27,7 +29,11 @@ class CapturesViewController: GalleryViewController {
galleryCollectionView.dataSource = self
galleryCollectionView.delegate = self
}

func localizableLabel() {
let formatStringGoalLabel = NSLocalizedString("Captures",
comment: "Captures")
self.title = String.localizedStringWithFormat(formatStringGoalLabel)
}
@objc func shouldEnableEditGallery() {
canEdit = !canEdit
if canEdit {
Expand All @@ -41,7 +47,9 @@ class CapturesViewController: GalleryViewController {
delegateTarget?.mediaTarget()
}
func enableEdit() {
editGalleryBarButtomItem.title = "Cancelar"
let formatStringCancel = NSLocalizedString("Cancel",
comment: "Cancel")
editGalleryBarButtomItem.title = formatStringCancel
for cell in galleryCollectionView.visibleCells {
guard let captureCell = cell as? CaptureCollectionViewCell else { continue }
captureCell.editable = true
Expand All @@ -50,7 +58,9 @@ class CapturesViewController: GalleryViewController {
}

func disableEdit() {
editGalleryBarButtomItem.title = "Editar"
let formatStringEdit = NSLocalizedString("Edit",
comment: "Edit")
editGalleryBarButtomItem.title = formatStringEdit
for cell in galleryCollectionView.visibleCells {
guard let captureCell = cell as? CaptureCollectionViewCell else { continue }
captureCell.editable = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,14 @@ class AudioViewController: MediaViewController {
weak var delegateTarget: MediaCollectionViewTargetDelegate?

override func viewWillAppear(_ animated: Bool) {
self.title = "Record"
localizableLabel()
}
func localizableLabel() {
let formatStringGoalLabel = NSLocalizedString("Record",
comment: "Record")
self.title = String.localizedStringWithFormat(formatStringGoalLabel)
}


// MARK: Controller methods
override func viewDidLoad() {
Expand Down
13 changes: 13 additions & 0 deletions en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,16 @@
"Drawing" = "Drawing";
"Videos" = "Videos" ;
"Captures" = "Captures";
"Record" = "Record";
"Media" = "Media";
"Happy" = "Happy";
"Sad" = "Sad";
"Angry" = "Angry";
"Anxious" = "Anxious";
"Indiferent" = "Indiferent";
"Grateful" = "Grateful";
"Surprised" = "Surprised";
"Tired" = "Tired";
"Edit" = "Edit";
"Cancel" = "Cancel";
"Add one goal here." = "Add one goal here.";
12 changes: 12 additions & 0 deletions pt-BR.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,15 @@ aa
"Drawing" = "Desenho";
"Videos" = "Videos" ;
"Captures" = "Fotos";
"Record" = "Audio";
"Happy" = "Feliz";
"Sad" = "Triste";
"Angry" = "Raiva";
"Anxious" = "Ansioso";
"Indiferent" = "Indiferente";
"Grateful" = "Grato";
"Surprised" = "Surpreso";
"Tired" = "Cansado";
"Edit" = "Editar";
"Cancel" = "Cancelar";
"Add one goal here." = "Adicione uma meta aqui.";

0 comments on commit 23d782f

Please sign in to comment.