It is currently 29 Oct 2025, 08:54
   
Text Size

Need for language library?

Post MTG Forge Related Programming Questions Here

Moderators: timmermac, Agetian, friarsol, Blacksmith, KrazyTheFox, CCGHQ Admins

Need for language library?

Postby 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.
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();
2. Verbs conjunction
Code: Select all
sb.append(" search").append(choosers.size() > 1 ? " " : "es ");
3. Possessive pronouns
Code: Select all
        String fetchPlayer = fetcherNames;
        if (chooserNames.equals(fetcherNames)) {
            fetchPlayer = fetchers.size() > 1 ? "their" : "his/her";
        }
The list is yet to be continued.

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?

Postby 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?

Postby moomarc » 03 Apr 2013, 12:00

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.
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.
-Marc
User avatar
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?

Postby 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.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: Need for language library?

Postby 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.
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?

Postby friarsol » 03 Apr 2013, 14:03

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.
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.

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?

Postby 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.
Single class for single responsibility.
Max mtg
Programmer
 
Posts: 1997
Joined: 02 Jul 2011, 14:26
Has thanked: 173 times
Been thanked: 334 times


Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 20 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 20 users online :: 0 registered, 0 hidden and 20 guests (based on users active over the past 10 minutes)
Most users ever online was 9298 on 10 Oct 2025, 12:54

Users browsing this forum: No registered users and 20 guests

Login Form