Truncated Strings
Closed this issue · 1 comments
Hi @woguan ,
I'm reporting this issue because my team and I are trying to localize this game to different language(s) for a school project (200% no commercial purpose). In your project, you made the description of characters go to different lines by hard-coded them. This, however, makes localization hard.
let firstLabel = SKLabelNode()
firstLabel.numberOfLines = 0
firstLabel.preferredMaxLayoutWidth = 1000
firstLabel.name = "character_menu_firstlabel"
firstLabel.horizontalAlignmentMode = .left
firstLabel.verticalAlignmentMode = .top
firstLabel.fontColor = .brown
**firstLabel.text = "She was born in the wilds and "**
firstLabel.lineBreakMode = NSLineBreakMode.byWordWrapping
firstLabel.fontName = "GillSans-Bold"
firstLabel.fontSize = firstlinebox.size.width/MAGICNUMBER
firstlinebox.addChild(firstLabel)
// 2nd Line
let secondlinebox = SKSpriteNode()
secondlinebox.name = "character_menu_secondlinebox"
secondlinebox.size = CGSize(width: txtBox.size.width, height: txtBox.size.height/3)
secondlinebox.anchorPoint = CGPoint(x: 0.0, y: 1.0)
secondlinebox.position.y = -secondlinebox.size.height
secondlinebox.color = .clear
txtBox.addChild(secondlinebox)
let secondLabel = SKLabelNode()
secondLabel.name = "character_menu_secondlabel"
secondLabel.horizontalAlignmentMode = .left
secondLabel.verticalAlignmentMode = .top
secondLabel.fontColor = .brown
**secondLabel.text = "raised by dragons. When dragons"**
secondLabel.fontName = "GillSans-Bold"
secondLabel.fontSize = secondlinebox.size.width/MAGICNUMBER
secondlinebox.addChild(secondLabel)
For example, in order to localize it, we need the firstLabel.text = "She was born in the wilds and "
and secondLabel.text = "raised by dragons. When dragons"
to be in the same label.text. Our team has googled and tried everything we could, but nothing has worked yet. Do you have any ideas how to make them multilined using the same label?
Thank you so much!!
Best,
Olivia
Hi Olivia,
I am super super sorry for answering this late. Since GitHub was not free to create private repositories, I have actually migrated to Bitbucket. But since GitHub recently changed their policy and it allows us to create private repo for free, so I am 'trying' to migrate back. Alright... going for your answer... when I started working on this project, as I recall, the SKLabel did not allow me to have multiple lines... and that was a workaround and I know it is hard for localizing it. With the current version of SpriteKit, they have added support for multiple lines, so you can combine those three labels into one single label and you can localize it.
Regards,
Diego