poio (version 0.0-4)

fix_metadata: Fix metadata in a PO object

Description

Fixes the metadata in a po object, as generated by read_po.

Usage

fix_metadata(x, pkg = ".", ..., .dots = list())

# S3 method for po fix_metadata( x, pkg = ".", clone = TRUE, file_type = x$file_type, ..., .dots = list() )

# S3 method for data.frame fix_metadata(x, pkg = ".", file_type, ..., .dots = list())

Arguments

x

An object of class po, or the data frame from the metadata element of such an object.

pkg

A path to the root of an R package source directory, or a package object, as created by as.package.

...

Named arguments of new metadata values.

.dots

A named list of new metadata values.

clone

Logical. If TRUE, the po object is cloned before the metadata is fixed. This has a slight performance cost, but is easier to reason about.

file_type

A string giving the file type; either "po" or "pot".

Value

An object of the same type as the input, but with the metadata fixed.

Details

Columns are added to ensure that the metadata data frame contains character columns named "name" and "value". Likewise rows are added or updated as follows.

Project-Id-Version

The package name and version, taken from the "Package" and "Version" fields of the DESCRIPTION file specified in the pkg argument.

Report-Msgid-Bugs-To

The URL to report bugs to, taken from the "BugReports" field of the DESCRIPTION file specified in the pkg argument.

POT-Creation-Date

Not auto-updated.

PO-Revision-Date

The current date and time, in format " and time formatting specifications.

Last-Translator

Your name and email, creepily autodetected by whoami, where possible.

Language-Team

Not auto-updated. Invent your own team name!

MIME-Version

Always changed to "1.0".

Content-Type

Always changed to "text/plain; charset=UTF-8".

Content-Transfer-Encoding

Always changed to "8bit".

Additionally PO, but not POT, files have these rows:

Language

An ISO 639-1 two-letter language code. See http://www.loc.gov/standards/iso639-2/php/code_list.php

Plural-Forms

The plural-form specification for the Language code.

Examples

Run this code
# NOT RUN {
pot_file <- system.file("extdata/R-summerof69.pot", package = "poio")
pot <- read_po(pot_file)
pot_fixed <- fix_metadata(pot, system.file(package = "poio"))

# Choose your own metadata
pot_fixed2 <- fix_metadata(
  pot,
  system.file(package = "poio"),
  "Last-Translator" = "Dr. Daniel Jackson <djackson@stargate.com>",
  .dots  = list(
    "Language-Team" = "Team RL10N!"
  )
)

# Compare the metadata before and after
pot$metadata
pot_fixed$metadata
# }

Run the code above in your browser using DataCamp Workspace