Merge pull request 'Add translation and conversion from one base to another' (#1) from development into main
Reviewed-on: #1
This commit is contained in:
commit
cfc7764fde
@ -7,26 +7,28 @@
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
2C53DAA62AF866B200EB233F /* AnyBaseConverter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C53DAA52AF866B200EB233F /* AnyBaseConverter.swift */; };
|
||||
2CCE3E9F2AF678B200BB0ED3 /* BinaryConverterApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CCE3E9E2AF678B200BB0ED3 /* BinaryConverterApp.swift */; };
|
||||
2CCE3EA12AF678B200BB0ED3 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CCE3EA02AF678B200BB0ED3 /* ContentView.swift */; };
|
||||
2CCE3EA32AF678B300BB0ED3 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 2CCE3EA22AF678B300BB0ED3 /* Assets.xcassets */; };
|
||||
2CCE3EA62AF678B300BB0ED3 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 2CCE3EA52AF678B300BB0ED3 /* Preview Assets.xcassets */; };
|
||||
2CCE3EAD2AF67A9000BB0ED3 /* UtilsFunctions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CCE3EAC2AF67A9000BB0ED3 /* UtilsFunctions.swift */; };
|
||||
2CCE3EAF2AF67BA900BB0ED3 /* BinaryConverter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CCE3EAE2AF67BA900BB0ED3 /* BinaryConverter.swift */; };
|
||||
2CCE3EB12AF67CFD00BB0ED3 /* HexaConverter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CCE3EB02AF67CFD00BB0ED3 /* HexaConverter.swift */; };
|
||||
2CCE3EB52AF6879200BB0ED3 /* OctalConverter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CCE3EB42AF6879200BB0ED3 /* OctalConverter.swift */; };
|
||||
2CEC5C712AFBF09800A6DEB3 /* BinaryConverter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CEC5C702AFBF09800A6DEB3 /* BinaryConverter.swift */; };
|
||||
2CEC5C752AFBF5BB00A6DEB3 /* Localizable.xcstrings in Resources */ = {isa = PBXBuildFile; fileRef = 2CEC5C742AFBF5BB00A6DEB3 /* Localizable.xcstrings */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
2C53DAA52AF866B200EB233F /* AnyBaseConverter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnyBaseConverter.swift; sourceTree = "<group>"; };
|
||||
2CCE3E9B2AF678B200BB0ED3 /* BinaryConverter.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = BinaryConverter.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
2CCE3E9E2AF678B200BB0ED3 /* BinaryConverterApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BinaryConverterApp.swift; sourceTree = "<group>"; };
|
||||
2CCE3EA02AF678B200BB0ED3 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
|
||||
2CCE3EA22AF678B300BB0ED3 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||
2CCE3EA52AF678B300BB0ED3 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
|
||||
2CCE3EAC2AF67A9000BB0ED3 /* UtilsFunctions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UtilsFunctions.swift; sourceTree = "<group>"; };
|
||||
2CCE3EAE2AF67BA900BB0ED3 /* BinaryConverter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BinaryConverter.swift; sourceTree = "<group>"; };
|
||||
2CCE3EB02AF67CFD00BB0ED3 /* HexaConverter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HexaConverter.swift; sourceTree = "<group>"; };
|
||||
2CCE3EB42AF6879200BB0ED3 /* OctalConverter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OctalConverter.swift; sourceTree = "<group>"; };
|
||||
2CEC5C702AFBF09800A6DEB3 /* BinaryConverter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BinaryConverter.swift; sourceTree = "<group>"; };
|
||||
2CEC5C742AFBF5BB00A6DEB3 /* Localizable.xcstrings */ = {isa = PBXFileReference; lastKnownFileType = text.json.xcstrings; path = Localizable.xcstrings; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
@ -61,10 +63,11 @@
|
||||
children = (
|
||||
2CCE3E9E2AF678B200BB0ED3 /* BinaryConverterApp.swift */,
|
||||
2CCE3EA02AF678B200BB0ED3 /* ContentView.swift */,
|
||||
2CCE3EB42AF6879200BB0ED3 /* OctalConverter.swift */,
|
||||
2CCE3EB02AF67CFD00BB0ED3 /* HexaConverter.swift */,
|
||||
2CCE3EAE2AF67BA900BB0ED3 /* BinaryConverter.swift */,
|
||||
2CEC5C702AFBF09800A6DEB3 /* BinaryConverter.swift */,
|
||||
2C53DAA52AF866B200EB233F /* AnyBaseConverter.swift */,
|
||||
2CCE3EAC2AF67A9000BB0ED3 /* UtilsFunctions.swift */,
|
||||
2CEC5C742AFBF5BB00A6DEB3 /* Localizable.xcstrings */,
|
||||
2CCE3EA22AF678B300BB0ED3 /* Assets.xcassets */,
|
||||
2CCE3EA42AF678B300BB0ED3 /* Preview Content */,
|
||||
);
|
||||
@ -121,6 +124,7 @@
|
||||
knownRegions = (
|
||||
en,
|
||||
Base,
|
||||
fr,
|
||||
);
|
||||
mainGroup = 2CCE3E922AF678B200BB0ED3;
|
||||
productRefGroup = 2CCE3E9C2AF678B200BB0ED3 /* Products */;
|
||||
@ -139,6 +143,7 @@
|
||||
files = (
|
||||
2CCE3EA62AF678B300BB0ED3 /* Preview Assets.xcassets in Resources */,
|
||||
2CCE3EA32AF678B300BB0ED3 /* Assets.xcassets in Resources */,
|
||||
2CEC5C752AFBF5BB00A6DEB3 /* Localizable.xcstrings in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@ -150,10 +155,10 @@
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
2CCE3EA12AF678B200BB0ED3 /* ContentView.swift in Sources */,
|
||||
2CCE3EAF2AF67BA900BB0ED3 /* BinaryConverter.swift in Sources */,
|
||||
2C53DAA62AF866B200EB233F /* AnyBaseConverter.swift in Sources */,
|
||||
2CCE3EAD2AF67A9000BB0ED3 /* UtilsFunctions.swift in Sources */,
|
||||
2CEC5C712AFBF09800A6DEB3 /* BinaryConverter.swift in Sources */,
|
||||
2CCE3EB12AF67CFD00BB0ED3 /* HexaConverter.swift in Sources */,
|
||||
2CCE3EB52AF6879200BB0ED3 /* OctalConverter.swift in Sources */,
|
||||
2CCE3E9F2AF678B200BB0ED3 /* BinaryConverterApp.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
@ -302,7 +307,7 @@
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 1.0;
|
||||
MARKETING_VERSION = 1.1;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = fr.louisgallet.BinaryConverter;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
|
||||
@ -336,7 +341,7 @@
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 1.0;
|
||||
MARKETING_VERSION = 1.1;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = fr.louisgallet.BinaryConverter;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
|
||||
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Bucket
|
||||
uuid = "B687202D-EECB-4F94-B02D-B86448789ACD"
|
||||
type = "1"
|
||||
version = "2.0">
|
||||
</Bucket>
|
60
BinaryConverter/AnyBaseConverter.swift
Normal file
60
BinaryConverter/AnyBaseConverter.swift
Normal file
@ -0,0 +1,60 @@
|
||||
//
|
||||
// AnyBaseConverter.swift
|
||||
// BinaryConverter
|
||||
//
|
||||
// Created by Louis Gallet on 06/11/2023.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct AnyBaseConverter: View {
|
||||
@State private var sourceBasedNumber: String = ""
|
||||
@State private var basedNumber: String = ""
|
||||
@State private var destinationBasedNumber: String = ""
|
||||
@State private var resultConversion: String = ""
|
||||
var body: some View {
|
||||
Form {
|
||||
Section(header: Text("Source base")) {
|
||||
TextField("Enter the source base for the number", text: $sourceBasedNumber)
|
||||
.keyboardType(.numberPad)
|
||||
}
|
||||
Section(header: Text("Destination base")) {
|
||||
TextField("Enter the arrival base",
|
||||
text: $destinationBasedNumber)
|
||||
.keyboardType(.numberPad)
|
||||
}
|
||||
|
||||
Section(header: Text("Number to convert")) {
|
||||
TextField("Enter the number that you want to convert",
|
||||
text: $basedNumber)
|
||||
.keyboardType(.numberPad)
|
||||
}
|
||||
|
||||
Section(header: Text("Result")) {
|
||||
Text("Your number in base \(destinationBasedNumber): \(resultConversion)")
|
||||
.contextMenu(ContextMenu(menuItems: {
|
||||
Button(action: {
|
||||
let pasteboard = UIPasteboard.general
|
||||
pasteboard.string = resultConversion
|
||||
}, label: {
|
||||
Label("Copy value", systemImage: "doc.on.doc")
|
||||
})
|
||||
}))
|
||||
}
|
||||
Button("Dismiss Keyboard") {
|
||||
UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil)
|
||||
}
|
||||
}
|
||||
.onChange(of: basedNumber) { newValue in
|
||||
if (!(destinationBasedNumber == "" || sourceBasedNumber == "")) {
|
||||
resultConversion = convertFromAnyBaseToAnyBase(basedNumber, fromBase: Int(sourceBasedNumber)!, toBase: Int(destinationBasedNumber) ?? 0)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
AnyBaseConverter()
|
||||
}
|
@ -18,6 +18,14 @@ struct BinaryConverter: View {
|
||||
}
|
||||
Section(header: Text("Base 2")) {
|
||||
Text("Your number in base 2: \(binaryNumber)")
|
||||
.contextMenu(ContextMenu(menuItems: {
|
||||
Button(action: {
|
||||
let pasteboard = UIPasteboard.general
|
||||
pasteboard.string = binaryNumber
|
||||
}, label: {
|
||||
Label("Copy value", systemImage: "doc.on.doc")
|
||||
})
|
||||
}))
|
||||
}
|
||||
Button("Dismiss Keyboard") {
|
||||
UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil)
|
||||
|
@ -12,8 +12,9 @@ struct ContentView: View {
|
||||
var body: some View {
|
||||
TabView(selection: $selectedTab,
|
||||
content: {
|
||||
BinaryConverter().tabItem { Image(systemName: "2.square.fill") ; Text("Binary") }.tag(0)
|
||||
HexaConverter().tabItem { Image(systemName: "16.square.fill") ; Text("Hexa") }.tag(1)
|
||||
BinaryConverter().tabItem { Image(systemName: "2.square.fill") ; Text("menu.conversion.binary") }.tag(0)
|
||||
HexaConverter().tabItem { Image(systemName: "16.square.fill") ; Text("menu.conversion.hexa") }.tag(1)
|
||||
AnyBaseConverter().tabItem { Image(systemName: "number.square.fill") ; Text("Any base") }.tag(2)
|
||||
|
||||
})
|
||||
}
|
||||
|
@ -18,6 +18,15 @@ struct HexaConverter: View {
|
||||
}
|
||||
Section(header: Text("Base 16")) {
|
||||
Text("Your number in base 16: \(HexadecimalNumber)")
|
||||
.contextMenu(ContextMenu(menuItems: {
|
||||
Button(action: {
|
||||
let pasteboard = UIPasteboard.general
|
||||
pasteboard.string = HexadecimalNumber
|
||||
|
||||
}, label: {
|
||||
Label("Copy value", systemImage: "doc.on.doc")
|
||||
})
|
||||
}))
|
||||
}
|
||||
Button("Dismiss Keyboard") {
|
||||
UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil)
|
||||
|
347
BinaryConverter/Localizable.xcstrings
Normal file
347
BinaryConverter/Localizable.xcstrings
Normal file
@ -0,0 +1,347 @@
|
||||
{
|
||||
"sourceLanguage" : "en",
|
||||
"strings" : {
|
||||
"Any base" : {
|
||||
"localizations" : {
|
||||
"en" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Any base"
|
||||
}
|
||||
},
|
||||
"fr" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Toutes bases"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Base 2" : {
|
||||
"localizations" : {
|
||||
"en" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Base 2"
|
||||
}
|
||||
},
|
||||
"fr" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Base 2"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Base 10" : {
|
||||
"comment" : "Same translation",
|
||||
"extractionState" : "manual",
|
||||
"localizations" : {
|
||||
"en" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Base 10"
|
||||
}
|
||||
},
|
||||
"fr" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Base 10"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Base 16" : {
|
||||
"localizations" : {
|
||||
"en" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Base 16"
|
||||
}
|
||||
},
|
||||
"fr" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Base 16"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Binary" : {
|
||||
"extractionState" : "stale",
|
||||
"localizations" : {
|
||||
"en" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Binary"
|
||||
}
|
||||
},
|
||||
"fr" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Binaire"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Copy value" : {
|
||||
"localizations" : {
|
||||
"en" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Copy value"
|
||||
}
|
||||
},
|
||||
"fr" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Copier la valeur"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Destination base" : {
|
||||
"localizations" : {
|
||||
"en" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Destination base"
|
||||
}
|
||||
},
|
||||
"fr" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Base de destination"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Dismiss Keyboard" : {
|
||||
"localizations" : {
|
||||
"en" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Dismiss Keyboard"
|
||||
}
|
||||
},
|
||||
"fr" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Fermer le clavier"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Enter the arrival base" : {
|
||||
"localizations" : {
|
||||
"en" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Enter the arrival base"
|
||||
}
|
||||
},
|
||||
"fr" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Entrer la base d'arrivée"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Enter the base 10 number here" : {
|
||||
"extractionState" : "manual",
|
||||
"localizations" : {
|
||||
"en" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Enter the base 10 number here"
|
||||
}
|
||||
},
|
||||
"fr" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Entrez le nombre en base 10 ici"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Enter the number that you want to convert" : {
|
||||
"localizations" : {
|
||||
"en" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Enter the number that you want to convert"
|
||||
}
|
||||
},
|
||||
"fr" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Entrez le nombre à convertir"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Enter the source base for the number" : {
|
||||
"localizations" : {
|
||||
"en" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Enter the source base for the number"
|
||||
}
|
||||
},
|
||||
"fr" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Entrez la base source"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Hexa" : {
|
||||
"extractionState" : "stale",
|
||||
"localizations" : {
|
||||
"en" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Hexa"
|
||||
}
|
||||
},
|
||||
"fr" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Hexa"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"menu.conversion.binary" : {
|
||||
"localizations" : {
|
||||
"en" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Binary"
|
||||
}
|
||||
},
|
||||
"fr" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Binaire"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"menu.conversion.hexa" : {
|
||||
"localizations" : {
|
||||
"en" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Hexa"
|
||||
}
|
||||
},
|
||||
"fr" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Hexadecimal"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Number to convert" : {
|
||||
"localizations" : {
|
||||
"en" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Number to convert"
|
||||
}
|
||||
},
|
||||
"fr" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Le nombre à convertir"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Result" : {
|
||||
"localizations" : {
|
||||
"en" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Result"
|
||||
}
|
||||
},
|
||||
"fr" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Résultat"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Source base" : {
|
||||
"localizations" : {
|
||||
"en" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Source base"
|
||||
}
|
||||
},
|
||||
"fr" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Base source"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Your number in base %@: %@" : {
|
||||
"localizations" : {
|
||||
"en" : {
|
||||
"stringUnit" : {
|
||||
"state" : "new",
|
||||
"value" : "Your number in base %1$@: %2$@"
|
||||
}
|
||||
},
|
||||
"fr" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Votre nombre en base %1$@: %2$@"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Your number in base 2: %@" : {
|
||||
"localizations" : {
|
||||
"en" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Your number in base 2: %@"
|
||||
}
|
||||
},
|
||||
"fr" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Votre nombre en base 2: %@"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Your number in base 16: %@" : {
|
||||
"localizations" : {
|
||||
"en" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Your number in base 16: %@"
|
||||
}
|
||||
},
|
||||
"fr" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Votre nombre en base 16: %@"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"version" : "1.0"
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
//
|
||||
// OctalConverter.swift
|
||||
// BinaryConverter
|
||||
//
|
||||
// Created by Louis Gallet on 04/11/2023.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct OctalConverter: View {
|
||||
var body: some View {
|
||||
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
OctalConverter()
|
||||
}
|
@ -29,3 +29,17 @@ func convertToHex(_ decimalString: String) -> String {
|
||||
return "Invalid Input"
|
||||
}
|
||||
}
|
||||
|
||||
/// Converts a number from the source base to the destination base
|
||||
/// - Parameters:
|
||||
/// - decimalString: The number that you want to convert
|
||||
/// - fromBase: The base of the number that you want to convert
|
||||
/// - toBase: The destination base
|
||||
/// - Returns: Return the number in toBase base or return "Invalid Input" if the input is not valid
|
||||
func convertFromAnyBaseToAnyBase(_ decimalString: String, fromBase: Int, toBase: Int) -> String {
|
||||
if let number = Int(decimalString, radix: fromBase) {
|
||||
return String(number, radix: toBase)
|
||||
} else {
|
||||
return "Invalid Input"
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user