Ejemplo n.º 1
0
// Looks up the msgID in the file of messages and returns a pointer to
// the beginning of the translated message, if found; and an empty string
// otherwise.
void
DjVuMessageLite::LookUpID( const GUTF8String &xmsgID,
                       GUTF8String &message_text,
                       GUTF8String &message_number ) const
{
  if(!Map.isempty())
  {
    GUTF8String msgID = xmsgID;
#if HAS_CTRL_C_IN_ERR_MSG
    int start = 0;
    while (msgID[start] == '\003') 
      start ++;
    if (start > 0)
      msgID = msgID.substr(start, msgID.length() - start);
#endif
    GPosition pos=Map.contains(msgID);
    if(pos)
    {
      const GP<lt_XMLTags> tag=Map[pos];
      GPosition valuepos=tag->get_args().contains(valuestring);
      if(valuepos)
      {
        message_text=tag->get_args()[valuepos];
      }else
      {
        const GUTF8String raw(tag->get_raw());
        const int start_line=raw.search((unsigned long)'\n',0);
      
        const int start_text=raw.nextNonSpace(0);
        const int end_text=raw.firstEndSpace(0);
        if(start_line<0 || start_text<0 || start_text < start_line)
        {
          message_text=raw.substr(0,end_text).fromEscaped();
        }else
        {
          message_text=raw.substr(start_line+1,end_text-start_line-1).fromEscaped();
        }
      }
      GPosition numberpos=tag->get_args().contains(numberstring);
      if(numberpos)
      {
        message_number=tag->get_args()[numberpos];
      }
    }
  }
}