chromium/ui/base/l10n/formatter.cc

// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/40285824): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "ui/base/l10n/formatter.h"

#include <limits.h>

#include <memory>
#include <ostream>
#include <vector>

#include "base/check.h"
#include "base/component_export.h"
#include "base/numerics/safe_conversions.h"
#include "third_party/icu/source/common/unicode/unistr.h"
#include "third_party/icu/source/i18n/unicode/msgfmt.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/strings/grit/ui_strings.h"

namespace ui {

COMPONENT_EXPORT(UI_BASE) bool formatter_force_fallback =;

struct Pluralities {};

static const Pluralities IDS_ELAPSED_SHORT_SEC =;

static const Pluralities IDS_ELAPSED_LONG_SEC =;

static const Pluralities IDS_ELAPSED_SHORT_MIN =;

static const Pluralities IDS_ELAPSED_LONG_MIN =;

static const Pluralities IDS_ELAPSED_HOUR =;
static const Pluralities IDS_ELAPSED_DAY =;
static const Pluralities IDS_ELAPSED_MONTH =;
static const Pluralities IDS_ELAPSED_YEAR =;

#if BUILDFLAG(IS_IOS)
static const Pluralities IDS_TITLE_CASE_ELAPSED_LONG_SEC = {
    IDS_TIME_TITLE_CASE_ELAPSED_LONG_SECS, "one{# Second Ago}",
    " other{# Seconds Ago}"};

static const Pluralities IDS_TITLE_CASE_ELAPSED_LONG_MIN = {
    IDS_TIME_TITLE_CASE_ELAPSED_LONG_MINS, "one{# Minute Ago}",
    " other{# Minutes Ago}"};

static const Pluralities IDS_TITLE_CASE_ELAPSED_HOUR = {
    IDS_TIME_TITLE_CASE_ELAPSED_HOURS, "one{# Hour Ago}",
    " other{# Hours Ago}"};

static const Pluralities IDS_TITLE_CASE_ELAPSED_DAY = {
    IDS_TIME_TITLE_CASE_ELAPSED_DAYS, "one{# Day Ago}", " other{# Days Ago}"};

static const Pluralities IDS_TITLE_CASE_ELAPSED_MONTH = {
    IDS_TIME_TITLE_CASE_ELAPSED_MONTHS, "one{# Month Ago}",
    " other{# Months Ago}"};

static const Pluralities IDS_TITLE_CASE_ELAPSED_YEAR = {
    IDS_TIME_TITLE_CASE_ELAPSED_YEARS, "one{# Year Ago}",
    " other{# Years Ago}"};
#endif

static const Pluralities IDS_REMAINING_SHORT_SEC =;
static const Pluralities IDS_REMAINING_SHORT_MIN =;

static const Pluralities IDS_REMAINING_LONG_SEC =;
static const Pluralities IDS_REMAINING_LONG_MIN =;
static const Pluralities IDS_REMAINING_HOUR =;
static const Pluralities IDS_REMAINING_DAY =;
static const Pluralities IDS_REMAINING_MONTH =;
static const Pluralities IDS_REMAINING_YEAR =;

static const Pluralities IDS_DURATION_SHORT_SEC =;
static const Pluralities IDS_DURATION_SHORT_MIN =;

static const Pluralities IDS_LONG_SEC =;
static const Pluralities IDS_LONG_MIN =;
static const Pluralities IDS_DURATION_HOUR =;
static const Pluralities IDS_DURATION_DAY =;
static const Pluralities IDS_DURATION_MONTH =;
static const Pluralities IDS_DURATION_YEAR =;

static const Pluralities IDS_LONG_MIN_1ST =;
static const Pluralities IDS_LONG_SEC_2ND =;
static const Pluralities IDS_DURATION_HOUR_1ST =;
static const Pluralities IDS_LONG_MIN_2ND =;
static const Pluralities IDS_DURATION_DAY_1ST =;
static const Pluralities IDS_DURATION_HOUR_2ND =;

namespace {

std::unique_ptr<icu::PluralRules> BuildPluralRules() {}

void FormatNumberInPlural(const icu::MessageFormat& format, int number,
                          icu::UnicodeString* result, UErrorCode* err) {}

}  // namespace

Formatter::Formatter(const Pluralities& sec_pluralities,
                     const Pluralities& min_pluralities,
                     const Pluralities& hour_pluralities,
                     const Pluralities& day_pluralities,
                     const Pluralities& month_pluralities,
                     const Pluralities& year_pluralities) {}

Formatter::Formatter(const Pluralities& sec_pluralities,
                     const Pluralities& min_pluralities,
                     const Pluralities& hour_pluralities,
                     const Pluralities& day_pluralities,
                     const Pluralities& month_pluralities,
                     const Pluralities& year_pluralities,
                     const Pluralities& min_sec_pluralities1,
                     const Pluralities& min_sec_pluralities2,
                     const Pluralities& hour_min_pluralities1,
                     const Pluralities& hour_min_pluralities2,
                     const Pluralities& day_hour_pluralities1,
                     const Pluralities& day_hour_pluralities2) {}

void Formatter::Format(Unit unit,
                       int value,
                       icu::UnicodeString* formatted_string) const {}

void Formatter::Format(TwoUnits units,
                       int value_1,
                       int value_2,
                       icu::UnicodeString* formatted_string) const {}

std::unique_ptr<icu::MessageFormat> Formatter::CreateFallbackFormat(
    const icu::PluralRules& rules,
    const Pluralities& pluralities) const {}

std::unique_ptr<icu::MessageFormat> Formatter::InitFormat(
    const Pluralities& pluralities) {}

const Formatter* FormatterContainer::Get(TimeFormat::Format format,
                                         TimeFormat::Length length) const {}

FormatterContainer::FormatterContainer() {}

FormatterContainer::~FormatterContainer() {}

void FormatterContainer::Initialize() {}

void FormatterContainer::Shutdown() {}

}  // namespace ui