Need for language library?
Post MTG Forge Related Programming Questions Here
Moderators: timmermac, Agetian, friarsol, Blacksmith, KrazyTheFox, CCGHQ Admins
7 posts
• Page 1 of 1
Need for language library?
by Max mtg » 02 Apr 2013, 14:47
http://svn.slightlymagic.net/websvn/dif ... &peg=20728
I was looking at all that beautiful string builders, and realzied that if we always build such pretty texts, we'll either copy-paste hundreds of lines or write a special library to perform common tasks.
1. Join homogeneous parts of the sentence.
Let me name advantages of use of a library: less duplicate code, easier localization to different languages - a single change of rules for text compisition for italian or whatever, will be better than any action on currently scattered texts.
Disadvantages: more complicated texts composition (one will have to look for a method for propper conjuction of lexical forms instead of just typing the strings),
This will be effective only if every developer adopts the system.
I was looking at all that beautiful string builders, and realzied that if we always build such pretty texts, we'll either copy-paste hundreds of lines or write a special library to perform common tasks.
1. Join homogeneous parts of the sentence.
- Code: Select all
final StringBuilder fetcherSB = new StringBuilder();
for (int i = 0; i < fetchers.size(); i++) {
fetcherSB.append(fetchers.get(i).getName());
fetcherSB.append((i + 2) == fetchers.size() ? " and " : (i + 1) == fetchers.size() ? "" : ", ");
}
final String fetcherNames = fetcherSB.toString();
- Code: Select all
sb.append(" search").append(choosers.size() > 1 ? " " : "es ");
- Code: Select all
String fetchPlayer = fetcherNames;
if (chooserNames.equals(fetcherNames)) {
fetchPlayer = fetchers.size() > 1 ? "their" : "his/her";
}
Let me name advantages of use of a library: less duplicate code, easier localization to different languages - a single change of rules for text compisition for italian or whatever, will be better than any action on currently scattered texts.
Disadvantages: more complicated texts composition (one will have to look for a method for propper conjuction of lexical forms instead of just typing the strings),
This will be effective only if every developer adopts the system.
Single class for single responsibility.
- Max mtg
- Programmer
- Posts: 1997
- Joined: 02 Jul 2011, 14:26
- Has thanked: 173 times
- Been thanked: 334 times
Re: Need for language library?
by Max mtg » 03 Apr 2013, 11:54
Looks like noone is interested. It's a pity to see the repeating codes, but we really have more important things to do, let's leave this subject alone for now.
Single class for single responsibility.
- Max mtg
- Programmer
- Posts: 1997
- Joined: 02 Jul 2011, 14:26
- Has thanked: 173 times
- Been thanked: 334 times
Re: Need for language library?
by moomarc » 03 Apr 2013, 12:00
I don't think that noone's interested, just that nobody with the necessary knowledge has time to commit to this while there's so many other bits that need work. It would be great to have a language library that makes localization easier, but its a huge undertaking (or seems that way to me at least) for a relatively small reward, and on parts of the code that, for now, do what they're supposed to. This is obviously easier for the first language English speakers to pass over though, and I do think it should probably happen some time in the future.Max mtg wrote:Looks like noone is interested. It's a pity to see the repeating codes, but we really have more important things to do, let's leave this subject alone for now.
-Marc
-

moomarc - Pixel Commander
- Posts: 2091
- Joined: 04 Jun 2010, 15:22
- Location: Johannesburg, South Africa
- Has thanked: 371 times
- Been thanked: 372 times
Re: Need for language library?
by friarsol » 03 Apr 2013, 12:17
Yea I think that's the hardest thing for most of the native English speakers. Forge is already in my spoken tongue, so the gain for me is pretty thin. Magic is a game where the official language is English. Sure they may print cards in different languages, but all Oracle text is in English and all the Official Rules text are in English.
So I can either spend time trying to get new ability features working like I do now with already limited time commitment, or I could spend time trying to setup hooks for translations I'll never see. While I think the idea is fine, things I don't gain personal benefit from I have a hard time "buying in" to that feature.
So I can either spend time trying to get new ability features working like I do now with already limited time commitment, or I could spend time trying to setup hooks for translations I'll never see. While I think the idea is fine, things I don't gain personal benefit from I have a hard time "buying in" to that feature.
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: Need for language library?
by Max mtg » 03 Apr 2013, 12:34
@Sol, it's not about translation (easier translation is a side effect), it's about elimination of numberles lines that you make vers and numbers conjunction.
The library's aim is to fight this kind of pasta:
sb.(player == Singletons.getControl().getLocalPlayer() ? "You" : p.toString()).append(" ").append("sacrifice").append(player == Singletons.getControl().getLocalPlayer() ? "" : "s").append(" ").append(list.size() == 1 ? "a" : "").append( list.size() == 1 && (new char[]{'aeiou'}).indexOf(list.get(0).toString().charAt(0)) >= 0 ? "n" : "").append(" ").append(StringUtils.join(list, ", "))
That produces nice "You sacrifice an artifact", "Amantha sacrifices a creature", "Mario sacrifices Tarmogoyf, Bottle Gnomes"
but is absolutelly unreadable.
The library's aim is to fight this kind of pasta:
sb.(player == Singletons.getControl().getLocalPlayer() ? "You" : p.toString()).append(" ").append("sacrifice").append(player == Singletons.getControl().getLocalPlayer() ? "" : "s").append(" ").append(list.size() == 1 ? "a" : "").append( list.size() == 1 && (new char[]{'aeiou'}).indexOf(list.get(0).toString().charAt(0)) >= 0 ? "n" : "").append(" ").append(StringUtils.join(list, ", "))
That produces nice "You sacrifice an artifact", "Amantha sacrifices a creature", "Mario sacrifices Tarmogoyf, Bottle Gnomes"
but is absolutelly unreadable.
Single class for single responsibility.
- Max mtg
- Programmer
- Posts: 1997
- Joined: 02 Jul 2011, 14:26
- Has thanked: 173 times
- Been thanked: 334 times
Re: Need for language library?
by friarsol » 03 Apr 2013, 14:03
Obviously if you write terribly obfuscated code it'll be hard to read. And if you have a few if statements to try to grammar proof things, and make the code easier to read, you'll have a little bit of code duplication.Max mtg wrote:@Sol, it's not about translation (easier translation is a side effect), it's about elimination of numberles lines that you make vers and numbers conjunction.
Put it up on the issue tracker, and let it sit in the back of people's minds for a bit. Maybe someone who lives in that code and is willing to do that task will get motivated and be up for doing it at some point in the future.
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: Need for language library?
by Max mtg » 03 Apr 2013, 14:22
Haven't seen the ugly tracker for long and I feel absolutelly no guilt about it.
I'll just leave this topic hanging here to attract some attention.
As for my personal position - I can tolerate the code duplications in text builders, while there are enough things to improve in game core... and then multiplayer awaits and then web-client and jogl-based 3D client to be implemented.
I also don't need translation of Forge, because there are more valuable things to do, and my English is good enough to play Magic without a dictionary.
Yet every day looking at commit logs, I notice how certain things could be done better. I started this topic to share that kind of ideas.
I'll just leave this topic hanging here to attract some attention.
As for my personal position - I can tolerate the code duplications in text builders, while there are enough things to improve in game core... and then multiplayer awaits and then web-client and jogl-based 3D client to be implemented.
I also don't need translation of Forge, because there are more valuable things to do, and my English is good enough to play Magic without a dictionary.
Yet every day looking at commit logs, I notice how certain things could be done better. I started this topic to share that kind of ideas.
Single class for single responsibility.
- Max mtg
- Programmer
- Posts: 1997
- Joined: 02 Jul 2011, 14:26
- Has thanked: 173 times
- Been thanked: 334 times
7 posts
• Page 1 of 1
Who is online
Users browsing this forum: Timothysow and 23 guests