I think one of the easiest ways to do it would be to ensure that the actual .swift files are all using the root language of the framework—akin to the development region of an app. Using metadata the IDE would dynamically substitute the localized names, but the underlying file would use the canonical values. Trying to store the localized code in the files makes using version control across language borders impossible.
Jeff Kelley [email protected] | @SlaunchaMan <https://twitter.com/SlaunchaMan> | jeffkelley.org <http://jeffkelley.org/> > On Mar 24, 2017, at 2:03 PM, Joshua Alvarado <[email protected]> > wrote: > > I wonder what it would do for reusability. It would be hard to share code > between countries written in Spanish or japanense unless the compiler could > convert the code to your language. Maybe properties and function calls could > be converted over to different languages but I am not sure Swift keywords > could be as easily converted which could lead to code with mixed languages > due to languages not mapping 1 to 1 on every word. This would be really cool > but a LOT of work. I think this is a bigger issue than just adding it into > Swift. Taking a look at non-English-based programming languages - > https://en.wikipedia.org/wiki/Non-English-based_programming_languages > <https://en.wikipedia.org/wiki/Non-English-based_programming_languages> - > there are very few, if any, highly used languages on the list. Some languages > implemented symbols instead of words so that it is not language based but > that would cause breaking changes in Swift :) > > It would be cool to see code in different languages: > > for i in foo { > print(i) > } > > para i en foo { > escribir(i) > } > > On Fri, Mar 24, 2017 at 11:28 AM, Jeff Kelley via swift-evolution > <[email protected] <mailto:[email protected]>> wrote: > One of the things that struck me from today’s Apple press release about Swift > Playgrounds being localized in more languages is this screenshot: > > <cn_playgrounds_looping.jpeg> > > All of the UI is fully localized for Chinese, except the actual code. As far > as I know, almost every major programming language and major platform > framework is primarily English; it’s become the de facto language for > developers. But does that have to be the case? > > Imagine a world where alongside our Swift frameworks, we ship .strings files > that contain translations of our APIs to other languages. From some other > screenshots we see that Swift Playgrounds is providing translations of method > names to explain them, here providing “avanzar” for “moveForward()”. > > <sp_playgrounds_stepping.jpeg> > > A scenario where Swift supported localized frameworks might see a .strings > file with a format like this: > > "moveForward()": "avanzar()" > > Then, in Swift code, whether through an IDE, some metadata in a comment in > the Swift file, or file extension (think “Foo.es.swift”), a developer who > selects Spanish could simply write avanzar() and understand it in her native > language. In fact, if the IDE is the layer that handles language selection, > two developers who don’t even speak the same language could collaborate on > code, and names from the framework would appear to each in their native > language! > > Comments and locally-defined names are of course still a barrier, but this > isn’t new. I know that “mazu” means “first” in Japanese thanks to some code I > worked on with an old coworker. > > This is obviously out of scope for Swift 4, and would require significant > effort to support, both technically in Swift itself and for those shipping > Swift frameworks, both inside and outside of Apple, to provided localized > names, so I wanted to throw this out to see if the community is even > interested. > > There’s just something about the idea of kids all over the world using Swift > Playgrounds completely in their own language that makes me think this could > help Swift achieve its stated goal of world dominance. > > > Jeff Kelley > > [email protected] <mailto:[email protected]> | @SlaunchaMan > <https://twitter.com/SlaunchaMan> | jeffkelley.org <http://jeffkelley.org/> > > _______________________________________________ > swift-evolution mailing list > [email protected] <mailto:[email protected]> > https://lists.swift.org/mailman/listinfo/swift-evolution > <https://lists.swift.org/mailman/listinfo/swift-evolution> > > > > > -- > Joshua Alvarado > [email protected] <mailto:[email protected]>
_______________________________________________ swift-evolution mailing list [email protected] https://lists.swift.org/mailman/listinfo/swift-evolution
