Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-4041-

is this considered good coding

Name: Anonymous 2012-01-01 13:14

the whole file is like this it is a  header file btw

char strSaveLoadReadyLoad[] = "@a004@s016@i@cffd8af Loading the above save data.";
#endif

#ifndef _ENGLISH    // 日本語
char strSaveLoadLoading[] = "@a004@s016@i@cffd8afもう一度、このセーブデータを選択すると、すぐに Load されます。";
#else                // 英語
char strSaveLoadLoading[] = "@a004@s016@i@cffd8af If you select it once more, the data will be loaded.";
#endif

#ifndef _ENGLISH    // 日本語
char strSaveLoadNoneTitle[] = "@s024@cffdf3f- タイトル無し -";
#else                // 英語
char strSaveLoadNoneTitle[] = "@s024@cffdf3f- No Title.";
#endif

#ifndef _ENGLISH    // 日本語
char strSaveLoadHelpInfoChange[] = "ファイル情報の表記を変更します。簡易タイトル、日時が交互に表示されます。";
#else                // 英語
char strSaveLoadHelpInfoChange[] = "Fight information display refreshed. Title and    date will be displayed.";
#endif

#ifndef _ENGLISH    // 日本語
char strSaveLoadHelpCall[] = "利用法についての詳細説明を見る事が出来ます。";
#else                // 英語
char strSaveLoadHelpCall[] = "You can view instructions on how to use this.";
#endif

#ifndef _ENGLISH    // 日本語
char strSaveLoadHelpCancel[] = "Load ファイルを選択している状態でも Cancel を選ぶと Load されずにゲームに戻ります。"
                        "@nSave 時は OK でも Cancel でも同じ効果です。";
#else                // 英語
char strSaveLoadHelpCancel[] = "Click cancel while selecting a file to load to    return to your current game.";
#endif

#ifndef _ENGLISH    // 日本語
char strSaveLoadHelpOk[] = "Load 時にファイルを選択して OK を選ぶと、データが Load されゲームが続きから始まります。"
                        "@nSave 時は、OK でも Cancel でも同じ効果です。";
#else                // 英語
char strSaveLoadHelpOk[] = "Click OK while selecting a file to load, and the  saved game will be loaded. ";
#endif

#ifndef _ENGLISH    // 日本語
char strSaveLoadHelpSaveTitle[] = "ゲーム中にしか使えません。";
#else                // 英語
char strSaveLoadHelpSaveTitle[] = "Only available during game play.";
#endif

#ifndef _ENGLISH    // 日本語
char strSaveLoadHelpSaveMode[] = "Save モードに切り替えます。";
#else                // 英語
char strSaveLoadHelpSaveMode[] = "Switch save mode.";
#endif

#ifndef _ENGLISH    // 日本語
char strSaveLoadHelpLoadMode[] = "Load モードに切り替えます。";
#else                // 英語
char strSaveLoadHelpLoadMode[] = "Switch load mode";
#endif

#ifndef _ENGLISH    // 日本語
char strSaveLoadHelpLoad[] = "@s016 Load するファイルを選択しました。Load する時は OK を押すか"
                        "@n@c9fefff同じファイル@cffffffを、@n@c9fefffもう一度選択@cffffffして下さい。@n"
                        " Load しない場合は、Cancel を選択するか ESC で抜けるか、右クリックして下さい。";
#else                // 英語
char strSaveLoadHelpLoad[] = "File selected. Click okay to load, or cancel to   cancel load operation.";
#endif

Name: Anonymous 2012-01-01 13:43

Well it doesn't really allow for a nice inclusion of further lanauges.

Really all strings should be in a text files and appropriate header could be generated by a bash/perl script

Name: Anonymous 2012-01-01 13:51

The correct way to do this would be to read from a map/hashtable, stored statically or in a file

something along the lines of:


--------
anus.h
--------

#define STR_IDX_ANUS 0
#define STR_IDX_FAGSTORM 1
#define STR_IDX_XARN 2
#define STR_IDX_HAX 3

char english_str_tbl[] =
{
   "Anus"
   "Fagstorm"
   "Xarn"
   "Hax"
}

char moonspeak_str_tbl[] =
{
   "モードに切り替えます"
   "選択しました"
   ...
}

#ifdef _ENGLISH
    #define _STRING_TABLE english_str_tbl
#else
    #define _STRING_TABLE moonspeak_str_tbl
#endif

--------
anus.c
--------

#include <anus.h>

void show_msg(int idx)
{
    puts(_STRING_TABLE[idx]);
}

Name: Anonymous 2012-01-01 13:52

Of course it is! If you are a monkey with 20 IQ.

Name: Anonymous 2012-01-01 13:54

>>3


char *english_str_tbl[] =
{
   "Anus"
   "Fagstorm"
   "Xarn"
   "Hax"
}

char *moonspeak_str_tbl[] =
{
   "モードに切り替えます"
   "選択しました"
   ...
}


FTFY.

Name: Anonymous 2012-01-01 13:59

OP never heard of modern i18n practices?

Code should look like

char* strSaveLoadNoneTitle = _("@a004@s016@i@cffd8af If you select it once more, the data will be loaded.");


And by modern I mean "modern for 1995". OP, read some SICP and then read gettext(3) and http://en.wikipedia.org/wiki/Gettext



Yeah, I helped him. Deal with it.

Name: Anonymous 2012-01-01 14:03

>>6
You helped him!

Name: Anonymous 2012-01-01 14:10

>>6
The OP wasn't asking for an OS specific solution you retard. In other words, >>5 got the answer (pretty much) right. Now shut your mouth you dumbass jew and leave the programming to the men.

Name: Anonymous 2012-01-01 14:16

>>5

what sucks about this solution is that you don't have translations side by side to compare

Name: 3-san 2012-01-01 14:19

>>9
Yep, but in a more practical implementation, you'd keep each language's strings in a different file, and than the problem is trivial (line numbers / comments / some smart format)

Name: Anonymous 2012-01-01 14:20

>>9
But that is a little bit better than the retard that suggested using gettext. Seriously. >>6 should have read the previous responses, and then, like tried to give more than 3 seconds worth of though before opening its mouth.

Name: kodak_gallery_programmer !!kCq+A64Losi56ze 2012-01-01 14:23

>>10
I've seen a lot of people take this one step further and have the computer automatically generate the code during the build itself.

Name: Anonymous 2012-01-01 14:29

Behold the utterly beauty of the most magnificent code you'll ever see.

Name: Anonymous 2012-01-01 14:30

>>8
It seems that some faggot doesn't know that gettext exists in every major OS. Oh well, can't expect better from /prog/

Name: Anonymous 2012-01-01 14:33

>>14
IT'S CALLED HAVING A FUCKING PORTABLE PROGRAM YOU JEW! NOW SHUT YOUR MOUTH AND GO SCRUB ANOTHER FUCKING TOILET YOU HOMOSEXUAL MIDGET.

Name: kodak_gallery_programmer !!kCq+A64Losi56ze 2012-01-01 14:35

>>14
Fail. I don't have gettext on Windows XP.

Name: Anonymous 2012-01-01 14:41

>>16
Well, install it. It's not that hard.

>>15
So what? gettext is portable for anyone with even ounce of brain.

Name: Anonymous 2012-01-01 14:41

>>6
gettext, aka GNU fascism

Nnnnnnope. I'd rather hack up my own localization library.

And then release it with a real opensource license, like MIT/X11.

Name: Anonymous 2012-01-01 14:44

Non-ascii string constants probably invoke undefined behaviour. Such is the life of a C programmer.

Name: Anonymous 2012-01-01 14:48

>>17
This coming from an idiot that probably doesn't even work as a computer programmer.

Name: Anonymous 2012-01-01 14:53

>>19
luckily we have L and _t, and ``w'' versions for string operations

Such is a the ignorance of a JAVA programmer

Name: Anonymous 2012-01-01 14:53

>>20
And this coming from retard with chronicle NIH-syndrome who wants to reinvent square wheels because he is too stupid to write normal programs, so instead he would prefer to waste his time to solve problems, solved 20 years ago.

Name: Anonymous 2012-01-01 14:55

>>22
You're talking out of your ass. Why don't you actually try and read a book for once in your life you fucking idiot. Oh wait, you can't, because you're just some dumb hourly worker that prefers to not do shit on their day off.

Name: Anonymous 2012-01-01 15:06

Here's how it should be done:


char* strSaveLoadNoneTitle = getstring("@a004@s016@i@cffd8af If you select it once more, the data will be loaded.");


getstring implementation and infrastructure left as an exercise for the reader.

Now what, GNU haters?

Name: Anonymous 2012-01-01 15:07

>>22
Well, if you had any clue about real world programming, you would have known that code re-usage is good and versions offered by >>3,5 (adding new languages? I better recompile the whole project). But well, since you never written anything harder than print 2+2 you can't know this.

Name: Anonymous 2012-01-01 15:17

>>1
#ifndef#elseif#endif#ifndef#elseif#endif#ifndef#elseif#endif#ifndef#elseif#endif#ifndef#elseif#endif#ifndef#elseif#endif#ifndef#elseif#endif#ifndef#elseif#endif#ifndef#elseif#endif#ifndef#elseif#endif#ifndef#elseif#endif#ifndef#elseif#endif#ifndef#elseif#endif#ifndef#elseif#endif#ifndef#elseif#endif#ifndef#elseif#endif#ifndef#elseif#endif#ifndef#elseif#endif#ifndef#elseif#endif#ifndef#elseif#endif#ifndef#elseif#endif#ifndef#elseif#endif#ifndef#elseif#endif#ifndef#elseif#endif#ifndef#elseif#endif#ifndef#elseif#endif#ifndef#elseif#endif#ifndef#elseif#endif#ifndef#elseif#endif#ifndef#elseif#endif#ifndef#elseif#endif#ifndef#elseif#endif#ifndef#elseif#endif#ifndef#elseif#endif#ifndef#elseif#endif#ifndef#elseif#endif#ifndef#elseif#endif#ifndef#elseif#endif#ifndef#elseif#endif#ifndef#elseif#endif#ifndef#elseif#endif#ifndef#elseif#endif#ifndef#elseif#endif#ifndef#elseif#endif#ifndef#elseif#endif#ifndef#elseif#endif#ifndef#elseif#endif#ifndef#elseif#endif#ifndef#elseif#endif#ifndef#elseif#endif#ifndef#elseif#endif#ifndef#elseif#endif#ifndef#elseif#endif#ifndef#elseif#endif#ifndef#elseif#endif#ifndef#elseif#endif


. . . Yet no header gaurds.

Name: kodak_gallery_programmer !!kCq+A64Losi56ze 2012-01-01 15:19

>>25
Uhh...I actually work as a Senior SOftware Engineer at Kodak you stupid shit. Again, you have zero clue as to what you're talking about. Now why don't you tell us what you do for a living. And plese cite your code contributions to any kind of major piece of software.

Name: Anonymous 2012-01-01 15:20

>>27
lol i trol u

Name: Anonymous 2012-01-01 15:20

PORTABILITY

Name: kodak_gallery_programmer !!kCq+A64Losi56ze 2012-01-01 15:22

>>25
(adding new languages? I better recompile the whole project).

That is by far the dumbest thing you've said so far. Half the time you don't need to recompile the whole project when you add a new language. The fact that you think you do leads to believe that you've never actually worked out in industry.

Name: Anonymous 2012-01-01 15:22

>>27
``software'' ``engineer''

Name: Anonymous 2012-01-01 15:23

>>28
I'm at work right now. Do you want to come over to st 300 on 63rd and Hollis here in emeryville and tell me that you toilet scrubber?

Name: Anonymous 2012-01-01 15:24

>>31
As opposed to your job title of "Utility Clerk" ?

Name: Anonymous 2012-01-01 15:25


>>32
go back to work

Name: Anonymous 2012-01-01 15:27

>>27
>>30
Please stop talking out your [b][i][o][u][sup]A][/sub]SS[/u][/o][/i][/b] about how you're some kind of godly programmer that knows how to do everything [b][i][o][u]R[sup]I[/sub]GHT[/u][/o][/i][/b] when you clearly don't. Let alone how you brag about working for all these good companies in all threads yet you make yourself out to be a total dipshit who probably hasn't let their mothers basement for the past 20 years.

Please go back to /g/ you shitty tripfag, no one likes you faggot.

Name: Anonymous 2012-01-01 15:28

>>34
You still haven't told us what you do for a living. You're obviously ashamed of the fact that you don't work as a computer programmer for a living. Now go run along and write some more toy programs you mental midget.

Name: Anonymous 2012-01-01 15:29

>>35
I don't know everything. I never claimed I did. However, what I do know, I know well. Now shut it.

Name: Anonymous 2012-01-01 15:29

[b][i][o][u][sup]A][/sub]SS[/u][/o][/i][/b]

Name: Anonymous 2012-01-01 15:29

A]SS

Name: Anonymous 2012-01-01 15:30

>>27
Senior SOftware Engineer at Kodak
http://www.linkedin.com/in/stevedeal
Steve Deal? Is that you? I will be calling your boss right now to have him reexamine his fellow Senior Software Engineer for sanity checks. You make your company look like shit.

Name: Anonymous 2012-01-01 15:31

It's like the special olympics, only s/physical/mental/

Name: Anonymous 2012-01-01 15:32

>>40
better than sherlock holmes.

Name: Anonymous 2012-01-01 15:37

>>40
Systems Analyst, Architect, Engineer, Developer and Integrator. Principal strengths in systems engineering and integration as well as software engineering and development.
I enjoy designing, developing, and implementing cost effective reliable solutions that require the integration of systems and software. It's a blast!

That doesn't sound like him, if it really was him it would've said something like:
Systems Analyst, Architect, Engineer, Developer and Integrator. Why are you reading this you mental midget, could you only get a job with hiring others, fit for someone like you, now go scrub another toilet.

Name: Anonymous 2012-01-01 15:43

>>40
Now that I think about it he's probably hired by Nikon or Canon to tarnish the reputation of Kodak.

Name: Anonymous 2012-01-01 15:50

>>44
Software Engineer Nikon Metrology

http://www.linkedin.com/in/karthickgopikrishnan

Software Developer TechWizard
Sounds like the type of place he would work at.

Name: Anonymous 2012-01-01 17:33

>>21
Great, now tell me what character encoding you're getting and how you're going to interface with your output system.

Name: Anonymous 2012-01-01 19:22

[code]enum StringList {
     SaveLoadReadyLoad,
     SaveLoadLoading,
     SaveLoadNoneTitle
     /* ... */
}

I would make an enum like this, and use these as indices into the string table.

#define stringize(...) _stringize(__VA_ARGS__)
#define _stringize(...) #__VA_ARGS__
#define concat(x,...) _concat(x,__VA_ARGS__)
#define _concat(x,...) x##__VA_ARGS__
#define LanguageHeader(x) stringize(concat(lang_,x).h)
#include LanguageHeader(LANGUAGE)

If you only want a string table for a single language in the executable, you can always use the preprocessor.

And then in a separate file, do:
/* lang_English.h */
const char *StringTable[] = {
     "@a004@s016@i@cffd8af Loading the above save data.",
     "@a004@s016@i@cffd8af If you select it once more, the data will be loaded.",
     "@s024@cffdf3f- No Title."
     /* ... */
};

Name: Anonymous 2012-01-01 19:32

char *name[] and not char **name
IHBT

Name: Anonymous 2012-01-01 22:57

programming stumps me, I mean what the hell does an _ in front of a variable this is not in any of the tutorials i've found and let alone how to get information from the OS and finding information about all library or namespace functions...

what the hell is this suppose to mean?

'char strSaveLoadReadyLoad[] = "@a004@s016@i@cffd8af Loading the above save data.";

Name: Anonymous 2012-01-01 23:08

>>49
__IS_FOR_STANDARD_AND_COMPILERS_ONLY__

Name: Anonymous 2012-01-01 23:34

Recompiling for every supported language considered fucking dumb.

Name: Anonymous 2012-01-01 23:44

>>51
yeah, and what if the person using the product wants to change languages? Could be better to store all these strings in a file and load the file at start up. Or include every string of every language hardcoded into the binary.

Name: Anonymous 2012-01-02 0:23

http://codepad.org/8W6oA0qY

I made my own one. It works pretty well.

You need a directory (in the example, it is just a directory called "translations"). Then you need a file for each language you want to translate into. If you had English and German, for example, you would have the files translations/english and translations/german. Every line in English has to be on the same line-number as its translation in German.

Example output:
[blockquote]$ ./lc.exe
Thank you Based Language Converter (English) = Vielen Dank Based Sprache Conver
er (German)[/blockquote]

Name: Anonymous 2012-01-02 0:26

>>53
Bear in mind I literally spent 30 minutes on this thing, so it's probably not robust.

I'm not sure whether it's better to have the user choose the source and destination languages just-in-time (when calling the Convert method) or ahead-of-time (when constructing the object). The former makes each Convert() call longer and more complex, while the latter requires having multiple objects. I went for the former in the end because I thought it was better, but IDK. Maybe if I was going to maintain that code I'd make it possible to do either.

Name: Anonymous 2012-01-02 1:14

Sorry, but you can't store Japanese characters in a char. You'll need a wchar.... and I'm pretty sure .c and .cpp files have to be ascii, so you'll need to find out the hex values of all those Japanese characters.

Name: Anonymous 2012-01-02 1:29

>>55
tell that to the game that works properly that i ripped it from

Name: Anonymous 2012-01-02 1:49

>>55
Or you could use 8-bit non-ASCII strings at runtime. Instead of figuring out what the hex values need to be, you can just use the corresponding ASCII value. I know of a few games that do this... and probably every 8-bit console game in Japanese does it.

Name: Anonymous 2012-01-02 2:00

ITT: /prog/ on the brink to rediscover utf8

Name: Anonymous 2012-01-02 2:20

>>53
c++ is shit

Name: Anonymous 2012-01-02 2:45

>>55
The code will work fine.

Name: Anonymous 2012-01-02 4:13

>>53
>>54
>not caching at all, not even naive caching
Enjoy your O(n) disk thrashing just to find the same string 1000 times.

Name: Anonymous 2012-01-02 16:49

>>55
and I'm pretty sure .c and .cpp files have to be ascii
Actually the encoding is unspecified. EBCDIC and Shift-JIS are perfectly acceptable character sets for C and C++ source code, that's why there are trigraphs and digraphs.

Name: Anonymous 2012-01-03 0:22

>>59
You're shit. C++ is a better progaming language than you'll ever be

>>61
I spent less than an hour on it. Also I like how you notice the lack of caching but not the fact that it breaks if there's a newline in srcString.

I'll add caching to the list of improvements to be made

Name: Anonymous 2012-01-03 7:04

>>63
To be honest I don't think any person is a good "progaming" language, or even programming language for that matter.

Name: >>64 2012-01-03 7:12

Granted, C++ is a really shitty language, it might so bad that it's actually worse than not having any programming language at all, in which case even people can be better programming languages than C++.

Name: Anonymous 2012-01-03 10:52

>>64
Jews make good programming languages, and even better pro-gaming languages.

Name: Anonymous 2012-01-03 12:43

Christians Did Perl 5!

Name: Anonymous 2012-01-03 13:00

>>64
Jew have been trolled

Name: Anonymous 2012-01-03 13:18

>>66
Jews are even better pogroming languages.

Name: Anonymous 2012-01-03 14:31

>>69
This guy.

Don't change these.
Name: Email:
Entire Thread Thread List