Comments (7)
Hey @gmarm. Thats nice! sure, that would be something that people will like to have I think.
How would you image it it will work in IB? With a couple of checkbox with Uppercased
and Capitalized
along with the text?
from iblocalizable.
Yes that's how I initially approached it, however it didn't work.
I tried adding a capitalized
and uppercased
property to the Localizable
protocol and then using their values in the applyLocalizableString(_ localizableString: String?)
method to set the text according to their values. This couldn't work however, because Swift does not allow for stored properties in extensions (unless you do it in a hacky way that I really didn't want to go for), therefore I couldn't create functional @IBInspectable
properties for capitalized
and uppercased
in the UI element extensions.
I did manage to make it work in a quick and less elegant way as can be seen here https://github.com/gmarm/IBLocalizable/pull/1, however I'm not happy with result. There are now three @IBInspectable
properties (two more than before, for capitalized and uppercase localizable strings) and the consumer can set any one of them. The disadvantage of this is that as mentioned there are three properties and the consumer is supposed to only set one, which is not made clear. Since I wasn't really content with the result, I didn't create a PR for your repo.
I would very much prefer to somehow get it working with an approach similar to the first one. If you have any ideas, lets discuss.
from iblocalizable.
Yes, like you mention you cant do stored properties in extensions without being hacky.
How about instead of using localizableStringToCapitalize
we have boolean
properties as capitalized
and uppercased
defaulting to false and then the applyLocalizableString
method will just check those values and modify the localized text accordingly.?
Thats a little better, no?
from iblocalizable.
As I said, that's what I initially tried, unless I'm missing something you're pointing out.
My main problem was the implementation of
@IBInspectable public var capitalized: Bool {
// implementation?
}
for example in the UIView
's Localizable
protocol conformance.
from iblocalizable.
@gmarm may be you can try something like that ;)
@IBInspectable public var uppercased: Bool {
get {
return false
}
set {
if newValue == true {
localizableString = localizableString.uppercaseString
}
}
}
from iblocalizable.
@HamzaGhazouani Thanks, that's interesting.
Although, is there any guarantee that setting uppercased
will get called after setting localizableString
? 😕
from iblocalizable.
Hi @gmarm, you should be sure that the uppercased
is below localizableString
in the User Defined Runtime attirbutes. it's not a real solution but a workaround... :/
from iblocalizable.
Related Issues (11)
- Declarations in extensions cannot override yet HOT 3
- Setting 'Localized Markup' of a UILabel gets rid of the selected text color
- Not working with Carthage installation HOT 12
- Overriding non-open var outside its defining module HOT 4
- Type 'UIControl' has no member 'State' build error HOT 2
- Manual Installation HOT 2
- Improve Sample Project
- Multiple items support is necessary HOT 6
- Change Language by manually HOT 3
- Swift 4 issue: Declarations in extensions cannot override yet HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from iblocalizable.