Skip to content

Commit

Permalink
ALFMOB-40: Refactored localizable files, moved some strings in genera…
Browse files Browse the repository at this point in the history
…l file
  • Loading branch information
timea-v committed Nov 18, 2024
1 parent 096b763 commit bb19848
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 76 deletions.
8 changes: 8 additions & 0 deletions Alfie/Alfie/Localisation/LocalizableGeneral.swift
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
import Foundation

struct LocalizableGeneral: LocalizableProtocol {
@LocalizableResource<Self>(.addToWishlist) static var addToWishlist
@LocalizableResource<Self>(.color) static var color
@LocalizableResource<Self>(.loading) static var loading
@LocalizableResource<Self>(.oneSize) static var oneSize
@LocalizableResource<Self>(.size) static var size
@LocalizableResource<Self>(.home) static var home
@LocalizableResource<Self>(.shop) static var shop
@LocalizableResource<Self>(.wishlist) static var wishlist
@LocalizableResource<Self>(.bag) static var bag

enum Keys: String, LocalizableKeyProtocol {
case addToWishlist = "KeyAddToWishlist"
case color = "KeyColor"
case loading = "KeyLoading"
case oneSize = "KeyOneSize"
case size = "KeySize"
case home = "TabKeyHome"
case shop = "TabKeyShop"
case wishlist = "TabKeyWishlist"
Expand Down
44 changes: 44 additions & 0 deletions Alfie/Alfie/Localisation/LocalizableGeneral.xcstrings
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
{
"sourceLanguage" : "en",
"strings" : {
"KeyAddToWishlist" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Add to wishlist"
}
}
}
},
"KeyColor" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Colour"
}
}
}
},
"KeyLoading" : {
"extractionState" : "manual",
"localizations" : {
Expand All @@ -12,6 +34,28 @@
}
}
},
"KeyOneSize" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "One Size"
}
}
}
},
"KeySize" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Size"
}
}
}
},
"TabKeyBag" : {
"extractionState" : "manual",
"localizations" : {
Expand Down
6 changes: 3 additions & 3 deletions Alfie/Alfie/Views/BagView/BagView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ struct BagView<ViewModel: BagViewModelProtocol>: View {
ForEach(mockContent.bagProducts) { product in
HorizontalProductCard(
product: product,
colorTitle: LocalizableProductDetails.$color + ":",
sizeTitle: LocalizableProductDetails.$size + ":",
oneSizeTitle: LocalizableProductDetails.$oneSize
colorTitle: LocalizableGeneral.$color + ":",
sizeTitle: LocalizableGeneral.$size + ":",
oneSizeTitle: LocalizableGeneral.$oneSize
)
.listRowInsets(EdgeInsets())
}
Expand Down
11 changes: 0 additions & 11 deletions Alfie/Alfie/Views/BagView/Localisation/LocalizableBag.xcstrings
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
{
"sourceLanguage" : "en",
"strings" : {
"KeyAddToWishlist" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Add to wishlist"
}
}
}
},
"KeyBag" : {
"extractionState" : "manual",
"localizations" : {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ struct ProductDetailsColorAndSizeSheet<ViewModel: ProductDetailsViewModelProtoco
// swiftlint:disable vertical_whitespace_between_cases
switch type {
case .color:
LocalizableProductDetails.$color
LocalizableGeneral.$color
case .size:
LocalizableProductDetails.$size
LocalizableGeneral.$size
}
// swiftlint:enable vertical_whitespace_between_cases
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,26 @@ struct LocalizableProductDetails: LocalizableProtocol {
@LocalizableResource<Self>(.complementaryInfoReturns) static var complementaryInfoReturns
@LocalizableResource<Self>(.productDescription) static var productDescription
@LocalizableResource<Self>(.addToBag) static var addToBag
@LocalizableResource<Self>(.addToWishlist) static var addToWishlist
@LocalizableResource<Self>(.outOfStock) static var outOfStock
@LocalizableResource<Self>(.shareTitleFrom) static var shareTitleFrom
@LocalizableResource<Self>(.errorTitle) static var errorTitle
@LocalizableResource<Self>(.errorNotFoundMessage) static var errorNotFoundMessage
@LocalizableResource<Self>(.errorGenericMessage) static var errorGenericMessage
@LocalizableResource<Self>(.errorButtonBackLabel) static var errorButtonBackLabel
@LocalizableResource<Self>(.color) static var color
@LocalizableResource<Self>(.searchColors) static var searchColors
@LocalizableResource<Self>(.size) static var size
@LocalizableResource<Self>(.oneSize) static var oneSize

enum Keys: String, LocalizableKeyProtocol {
case complementaryInfoDelivery = "KeyComplementaryInfoDelivery"
case complementaryInfoPayment = "KeyComplementaryInfoPayment"
case complementaryInfoReturns = "KeyComplementaryInfoReturns"
case productDescription = "KeyProductDescription"
case addToBag = "KeyAddToBag"
case addToWishlist = "KeyAddToWishlist"
case outOfStock = "KeyOutOfStock"
case shareTitleFrom = "KeyShareTitleFrom"
case errorTitle = "KeyErrorTitle"
case errorNotFoundMessage = "KeyErrorNotFoundMessage"
case errorGenericMessage = "KeyErrorGenericMessage"
case errorButtonBackLabel = "KeyErrorButtonBackLabel"
case color = "KeyColor"
case searchColors = "KeySearchColors"
case size = "KeySize"
case oneSize = "KeyOneSize"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,6 @@
}
}
},
"KeyAddToWishlist" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Add to Wish List"
}
}
}
},
"KeyColor" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Colour"
}
}
}
},
"KeyComplementaryInfoDelivery" : {
"extractionState" : "manual",
"localizations" : {
Expand Down Expand Up @@ -111,17 +89,6 @@
}
}
},
"KeyOneSize" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "One Size"
}
}
}
},
"KeyOutOfStock" : {
"extractionState" : "manual",
"localizations" : {
Expand Down Expand Up @@ -165,17 +132,6 @@
}
}
}
},
"KeySize" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Size"
}
}
}
}
},
"version" : "1.0"
Expand Down
6 changes: 3 additions & 3 deletions Alfie/Alfie/Views/ProductDetails/ProductDetailsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -448,9 +448,9 @@ extension ProductDetailsView {
@ViewBuilder private var singleSizeView: some View {
let sizeText: String = isOneSize
? (viewModel.sizingSelectionConfiguration.items.first?.name ?? "")
: LocalizableProductDetails.$oneSize
: LocalizableGeneral.$oneSize
HStack {
Text.build(theme.font.small.bold(LocalizableProductDetails.$size + ":"))
Text.build(theme.font.small.bold(LocalizableGeneral.$size + ":"))
.foregroundStyle(Colors.primary.mono900)
Text.build(theme.font.small.normal(sizeText))
.foregroundStyle(Colors.primary.mono900)
Expand Down Expand Up @@ -535,7 +535,7 @@ extension ProductDetailsView {
if viewModel.shouldShow(section: .addToWishlist) {
VStack(spacing: Spacing.space0) {
ThemedButton(
text: LocalizableProductDetails.$addToWishlist,
text: LocalizableGeneral.$addToWishlist,
style: .secondary,
isFullWidth: true
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ final class ProductDetailsViewModel: ProductDetailsViewModelProtocol {
}

colorSelectionConfiguration = .init(
selectedTitle: LocalizableProductDetails.$color + ":",
selectedTitle: LocalizableGeneral.$color + ":",
items: colorSwatches,
selectedItem: selectedSwatch
)
Expand Down Expand Up @@ -277,7 +277,7 @@ final class ProductDetailsViewModel: ProductDetailsViewModelProtocol {
}

sizingSelectionConfiguration = .init(
selectedTitle: LocalizableProductDetails.$size + ":",
selectedTitle: LocalizableGeneral.$size + ":",
items: sizingSwatches,
selectedItem: selectedSwatch
)
Expand Down
6 changes: 3 additions & 3 deletions Alfie/Alfie/Views/WishListView/WishListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ struct WishListView: View {
VerticalProductCard(
configuration: .init(size: .medium, hideDetails: false, actionType: .remove),
product: product,
colorTitle: LocalizableProductDetails.$color + ":",
sizeTitle: LocalizableProductDetails.$size + ":",
oneSizeTitle: LocalizableProductDetails.$oneSize
colorTitle: LocalizableGeneral.$color + ":",
sizeTitle: LocalizableGeneral.$size + ":",
oneSizeTitle: LocalizableGeneral.$oneSize
) { productId, type in
guard case .remove = type else { return }
mockContent.wishlistProducts = mockContent.wishlistProducts.filter { $0.id != productId }
Expand Down

0 comments on commit bb19848

Please sign in to comment.