AM / PM 「上午」和「下午」翻譯處理



  • 大家好

    我正要將 AM 和 PM 翻譯為「上午」和「下午」,但翻譯之後時間格式就要由 H:MM AP 改為 AP H:MM ,localization 會處理嗎?



  • 你可以试试 "QLocale":http://doc.qt.nokia.com/latest/qlocale.html#toString-6 吗?
    @
    QLocale chineseLocale(QLocale::Chinese);
    QDateTime currentDateTime = QDateTime::currentDateTime();
    QString chineseTimeString = chineseLocale.toString(currentDateTime, QString("AP hh:mm:ss"));
    QString chineseTimeShortFormatString = chineseLocale.toString(currentDateTime, QLocale::ShortFormat);
    @





  • 如無人反對我就會將繁體中文版 AM 和 PM 翻譯為「上午」和「下午」



  • 我用楼上的建议,写了如下的示例代码:
    @
    #include <QtCore/QCoreApplication>
    #include <QtCore/QLocale>
    #include <QtCore/QDateTime>
    #include <QtCore/QTextStream>

    int main(int argc, char *argv[])
    {
    QCoreApplication a(argc, argv);

    QLocale chineseLocale(QLocale::Chinese);
    QDateTime currentDateTime = QDateTime::currentDateTime();
    QString TimeString = chineseLocale.toString(currentDateTime, QString("AP hh:mm:ss"));
    QString TimeLongFormatString = chineseLocale.toString(currentDateTime, QLocale::LongFormat);
    QString TimeShortFormatString = chineseLocale.toString(currentDateTime, QLocale::ShortFormat);
    QString TimeNarrowFormatString = chineseLocale.toString(currentDateTime, QLocale::NarrowFormat);
    QTextStream cout(stdout, QIODevice::WriteOnly);
    cout<<TimeString<<endl;
    cout<<TimeLongFormatString<<endl;
    cout<<TimeShortFormatString<<endl;
    cout<<TimeNarrowFormatString<<endl;
    cout<<chineseLocale.amText()<<endl;
    cout<<chineseLocale.pmText()<<endl;
    
    return a.exec&#40;&#41;;
    

    }
    @
    输出结果为
    PM 06:40:38
    2012年8月24日星期五 中国标准时间PM6时40分38秒
    12-8-24 PM6:40
    12-8-24 PM6:40
    上午
    下午
    诚如楼上所言,前四行中的PM(AM)翻译为下午(上午)更为合适些!
    [quote author="wwycheuk" date="1332551640"]如無人反對我就會將繁體中文版 AM 和 PM 翻譯為「上午」和「下午」[/quote]


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.