LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-19-2006, 02:33 AM   #1
mic
Member
 
Registered: Jun 2005
Posts: 44

Rep: Reputation: 16
Limit a string length for translation?


I'm using C and gettext to write some strings to a small display.

How do I force or at least tell translators to limit their translated string to some maximum length which could still be displayed? This max length depends on a string so it should be specified for each string separately.

Font is a monospace type, so all characters are the same length. Only the number of characters matters.

One bad and primitive solution would be to make all original (untranslated) strings of max length by adding underscores to each original string. Is there any better way, or anything that is already widely accepted and commonly used?
 
Old 01-20-2006, 11:33 AM   #2
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
i'm not an expert on this but this makes sense.
i guess after gettext() does its thing, truncate the result to however many bytes:
[pseudo-code]
Code:
if strlen(c_string) > max
   c_string[max] = '\0'
[/pseudo-code]
not sure why you would want to underscore-pad the input (is the probelm the input is too long or too small?)

edit: i see - your solution would make everything constant len.
(a small waste of mem)

Last edited by schneidz; 01-20-2006 at 11:35 AM.
 
Old 01-20-2006, 01:06 PM   #3
mic
Member
 
Registered: Jun 2005
Posts: 44

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by schneidz
Code:
if strlen(c_string) > max
   c_string[max] = '\0'
This is already done anyway. I want the translators to know for each string how long can it be to be still shown as a whole. Then they could make a shorter translation that would not get truncated, e.g. they could use another shorter words with same meaning, or use abbreviations when needed - and only when needed.

It would be best if a translation program like KBabel would recognise this information and prevent the translator from entering too many characters for a particular translation. Or at least show him this info somehow.
 
Old 01-20-2006, 06:58 PM   #4
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
i guess you would need a dictionary (table) of certain words and an appropriate abbrev.

your loop would contain a control of:
- if len is > max
- look for strings that exist in that table
- if it exists substitute it for the abbrev.

thats the only thing i can think of
______________

is it possible you can parse the output into max-len peices and then show each peice in order?

Last edited by schneidz; 01-20-2006 at 07:04 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
i want to help in the translation of gnucash AGazzaz Linux - General 1 11-28-2005 04:03 PM
is there any limit for string length in basic_string? pippet Programming 13 02-01-2005 06:58 AM
java test if string in string array is null. exodist Programming 3 02-21-2004 01:39 PM
Quota issue, hard limit doesn't limit users Gratz Linux - Software 2 09-16-2003 07:35 AM
translation? rebelcan Linux - General 1 07-28-2003 02:07 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:20 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration