VIVO-347 "Spanish" display names for PropertyConfig.n3
Create Ruby scripts to help in the translation. Put the translated labels into PropertyConfig_es.n3
This commit is contained in:
parent
06f3e9f843
commit
48181193b7
4 changed files with 310 additions and 0 deletions
44
languages/example/rdf/display/everytime/PropertyConfig_es.n3
Normal file
44
languages/example/rdf/display/everytime/PropertyConfig_es.n3
Normal file
|
@ -0,0 +1,44 @@
|
|||
<http://example.org/appConfig/adviseeRoleConfig> <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationConfiguration#displayName> "aconsejado en"@es .
|
||||
<http://example.org/appConfig/editorOfConfig> <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationConfiguration#displayName> "editor de"@es .
|
||||
<http://example.org/appConfig/educationalTrainingConfig> <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationConfiguration#displayName> "la educaci\u00F3n y la formaci\u00F3n"@es .
|
||||
<http://example.org/appConfig/hasOutreachProviderRoleConfig> <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationConfiguration#displayName> "extensi\u00F3n y servicio a la comunidad"@es .
|
||||
<http://example.org/appConfig/hasServiceProviderRoleConfig> <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationConfiguration#displayName> "servicio a la profesi\u00F3n"@es .
|
||||
<http://example.org/appConfig/orgTelephoneConfig> <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationConfiguration#displayName> "tel\u00E9fono"@es .
|
||||
<http://example.org/appConfig/organizationForPositionConfig> <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationConfiguration#displayName> "personas"@es .
|
||||
<http://example.org/appConfig/webpageConfig> <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationConfiguration#displayName> "p\u00E1gina web"@es .
|
||||
<http://example.org/appConfig/hasResearcherRoleConfig> <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationConfiguration#displayName> "actividades de investigaci\u00F3n"@es .
|
||||
<http://example.org/appConfig/inEventSeriesConfig> <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationConfiguration#displayName> "en la serie de eventos"@es .
|
||||
<http://example.org/appConfig/hasEditorRoleConfig> <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationConfiguration#displayName> "recogida o editor de la serie de"@es .
|
||||
<http://example.org/appConfig/hasTeacherRoleConfig> <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationConfiguration#displayName> "actividades docentes"@es .
|
||||
<http://example.org/appConfig/personInPositionConfig> <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationConfiguration#displayName> "posiciones"@es .
|
||||
<http://example.org/appConfig/preferredTitleConfig> <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationConfiguration#displayName> "t\u00EDtulo preferido"@es .
|
||||
<http://example.org/appConfig/authorInAuthorshipConfig> <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationConfiguration#displayName> "publicaciones seleccionadas"@es .
|
||||
<http://example.org/appConfig/fullNameConfig> <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationConfiguration#displayName> "nombre y apellidos"@es .
|
||||
<http://example.org/appConfig/hasReviewerRoleConfig> <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationConfiguration#displayName> "revisor de"@es .
|
||||
<http://example.org/appConfig/informationResourceInAuthorshipConfig> <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationConfiguration#displayName> "autores"@es .
|
||||
<http://example.org/appConfig/hasAttendeeRoleConfig> <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationConfiguration#displayName> "asistido"@es .
|
||||
<http://example.org/appConfig/includesEventConfig> <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationConfiguration#displayName> "incluye eventos"@es .
|
||||
<http://example.org/appConfig/primaryEmailConfig> <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationConfiguration#displayName> "correo electr\u00F3nico principal"@es .
|
||||
<http://example.org/appConfig/hasCo-PrincipalInvestigatorRoleConfig> <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationConfiguration#displayName> "investigador co-principal en"@es .
|
||||
<http://example.org/appConfig/personFaxConfig> <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationConfiguration#displayName> "fax"@es .
|
||||
<http://example.org/appConfig/grantRelatesConfig> <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationConfiguration#displayName> "contribuyente"@es .
|
||||
<http://example.org/appConfig/informationResourceInEditorshipConfig> <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationConfiguration#displayName> "editores"@es .
|
||||
<http://example.org/appConfig/mailingAddressConfig> <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationConfiguration#displayName> "direcci\u00F3n de env\u00EDo"@es .
|
||||
<http://example.org/appConfig/orgFaxConfig> <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationConfiguration#displayName> "fax"@es .
|
||||
<http://example.org/appConfig/hasOrganizerRoleConfig> <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationConfiguration#displayName> "organizador del"@es .
|
||||
<http://example.org/appConfig/hasPrincipalInvestigatorRoleConfig> <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationConfiguration#displayName> "investigador principal en"@es .
|
||||
<http://example.org/appConfig/additionalEmailConfig> <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationConfiguration#displayName> "correos electr\u00F3nicos adicionales"@es .
|
||||
<http://example.org/appConfig/advisorRoleConfig> <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationConfiguration#displayName> "asesorados"@es .
|
||||
<http://example.org/appConfig/awardOrHonorConfig> <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationConfiguration#displayName> "premios y honores"@es .
|
||||
<http://example.org/appConfig/awardOrHonorReceiptsConfig> <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationConfiguration#displayName> "ingresos"@es .
|
||||
<http://example.org/appConfig/awardReceiptsConfig> <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationConfiguration#displayName> "la recepci\u00F3n de"@es .
|
||||
<http://example.org/appConfig/hasInvestigatorRoleConfig> <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationConfiguration#displayName> "investigador en"@es .
|
||||
<http://example.org/appConfig/awardReceiptsAwardForConfig> <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationConfiguration#displayName> "premio o el honor de"@es .
|
||||
<http://example.org/appConfig/eventWithinConfig> <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationConfiguration#displayName> "caso, dentro de"@es .
|
||||
<http://example.org/appConfig/hasClinicalRoleConfig> <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationConfiguration#displayName> "actividades cl\u00EDnicas"@es .
|
||||
<http://example.org/appConfig/hasPresenterRoleConfig> <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationConfiguration#displayName> "presentaciones"@es .
|
||||
<http://example.org/appConfig/testRemovalConfig> <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationConfiguration#displayName> "relacionados por"@es .
|
||||
<http://example.org/appConfig/bfo_0000055Config> <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationConfiguration#displayName> "part\u00EDcipe"@es .
|
||||
<http://example.org/appConfig/hasLeaderRoleConfig> <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationConfiguration#displayName> "jefe de"@es .
|
||||
<http://example.org/appConfig/hasMemberRoleConfig> <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationConfiguration#displayName> "miembro de"@es .
|
||||
<http://example.org/appConfig/personTelephoneConfig> <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationConfiguration#displayName> "tel\u00E9fono"@es .
|
47
utilities/languageSupport/translateDisplayNames/display_name_common.rb
Executable file
47
utilities/languageSupport/translateDisplayNames/display_name_common.rb
Executable file
|
@ -0,0 +1,47 @@
|
|||
#!/usr/bin/ruby
|
||||
=begin
|
||||
--------------------------------------------------------------------------------
|
||||
--------------------------------------------------------------------------------
|
||||
=end
|
||||
|
||||
require 'rubygems'
|
||||
require 'rdf'
|
||||
require 'rdf/rdfxml'
|
||||
require 'rdf/ntriples'
|
||||
require 'rdf/n3'
|
||||
|
||||
include RDF
|
||||
|
||||
DISPLAY_NAME_URI = RDF::URI.new("http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationConfiguration#displayName")
|
||||
|
||||
class UsageError < StandardError; end
|
||||
class FilterError < StandardError; end
|
||||
|
||||
|
||||
class DisplayNameCommon
|
||||
# ------------------------------------------------------------------------------------
|
||||
private
|
||||
# ------------------------------------------------------------------------------------
|
||||
|
||||
# ------------------------------------------------------------------------------------
|
||||
public
|
||||
# ------------------------------------------------------------------------------------
|
||||
|
||||
def self.load_filter(filter_file)
|
||||
return lambda{|s| true} unless filter_file
|
||||
return eval(IO.read(filter_file))
|
||||
rescue
|
||||
raise FilterError.new($!.message)
|
||||
end
|
||||
|
||||
def initialize(rdf_file, &filter)
|
||||
@filter = filter.nil? ? lambda{true} : filter
|
||||
@graph = Graph.load(rdf_file)
|
||||
end
|
||||
|
||||
def process(query, &filter)
|
||||
solutions = query.execute(@graph)
|
||||
solutions.filter!(&filter)
|
||||
solutions.order(:prop)
|
||||
end
|
||||
end
|
|
@ -0,0 +1,118 @@
|
|||
#!/usr/bin/ruby
|
||||
=begin
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
A utility that reads an RDF file, builds a model, sorts all of the URIs that have
|
||||
display_names, and associates those URIs with the display_names in a supplied text file, one line
|
||||
per display_name.
|
||||
|
||||
These display_names are assigned the language specified on the command line, and the
|
||||
resulting RDF statements are sent to standard output as N3.
|
||||
|
||||
On the command line provide the path to the RDF file, the path to the display_names file,
|
||||
and the desired language/locale. E.g.:
|
||||
|
||||
display_name_inserter.rb ../../vivo-core-1.5-annotations.rdf display_names.file es_ES
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
=end
|
||||
|
||||
$: << File.dirname(File.expand_path(__FILE__))
|
||||
require 'rubygems'
|
||||
require 'rdf'
|
||||
require 'display_name_common'
|
||||
|
||||
include RDF
|
||||
|
||||
class DisplayNameInserter
|
||||
# ------------------------------------------------------------------------------------
|
||||
private
|
||||
# ------------------------------------------------------------------------------------
|
||||
|
||||
#
|
||||
# Parse the arguments and complain if they don't make sense.
|
||||
#
|
||||
def sanity_check_arguments(args)
|
||||
raise UsageError, "usage is: display_name_inserter.rb <rdf_file> <display_names_input_file> <locale> [filter_file] <n3_output_file> [ok]" unless (3..5).include?(args.length)
|
||||
|
||||
if args[-1].downcase == 'ok'
|
||||
ok = true
|
||||
args.pop
|
||||
else
|
||||
ok = false
|
||||
end
|
||||
|
||||
n3_output_file = args.pop
|
||||
raise UsageError, "File '#{n3_output_file}' already exists. specify 'ok' to overwrite it." if File.exist?(n3_output_file) && !ok
|
||||
|
||||
rdf_file = args[0]
|
||||
raise UsageError, "File '#{rdf_file}' does not exist." unless File.exist?(rdf_file)
|
||||
|
||||
display_names_input_file = args[1]
|
||||
raise UsageError, "File '#{display_names_input_file}' does not exist." unless File.exist?(display_names_input_file)
|
||||
|
||||
locale = args[2]
|
||||
raise UsageError, "Locale should be like 'ab' or 'ab-CD'." unless /^[a-z]{2}(-[A-Z]{2})?$/ =~ locale
|
||||
|
||||
filter_file = args[3]
|
||||
raise UsageError, "File '#{filter_file}' does not exist." if filter_file && !File.exist?(filter_file)
|
||||
filter = DisplayNameCommon.load_filter(filter_file)
|
||||
|
||||
return rdf_file, display_names_input_file, locale, filter, n3_output_file
|
||||
end
|
||||
|
||||
# ------------------------------------------------------------------------------------
|
||||
public
|
||||
# ------------------------------------------------------------------------------------
|
||||
|
||||
def initialize(args)
|
||||
@rdf_file, @display_names_input_file, @locale, @filter, @n3_output_file = sanity_check_arguments(args)
|
||||
rescue UsageError => e
|
||||
puts "\n----------------\nUsage error\n----------------\n\n#{e}\n\n----------------\n\n"
|
||||
exit
|
||||
rescue FilterError => e
|
||||
puts "\n----------------\nFilter file is invalid\n----------------\n\n#{e}\n\n----------------\n\n"
|
||||
exit
|
||||
end
|
||||
|
||||
def process()
|
||||
query = Query.new({
|
||||
:prop => {
|
||||
DISPLAY_NAME_URI => :display_name,
|
||||
}
|
||||
})
|
||||
|
||||
solutions = DisplayNameCommon.new(@rdf_file).process(query, &@filter)
|
||||
|
||||
display_names = IO.readlines(@display_names_input_file)
|
||||
|
||||
raise "Number of display_names (#{display_names.length}) doesn't match number of URIs (#{solutions.length})" unless display_names.length == solutions.length
|
||||
|
||||
graph = Graph.new
|
||||
solutions.zip(display_names).each do |data|
|
||||
s = data[0].prop
|
||||
p = DISPLAY_NAME_URI
|
||||
o = Literal.new(data[1].chomp, :language => @locale)
|
||||
graph << Statement.new(s, p, o)
|
||||
end
|
||||
|
||||
File.open(@n3_output_file, 'w') do |f|
|
||||
f.puts graph.dump(:ntriples)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
#
|
||||
# ------------------------------------------------------------------------------------
|
||||
# Standalone calling.
|
||||
#
|
||||
# Do this if this program was called from the command line. That is, if the command
|
||||
# expands to the path of this file.
|
||||
# ------------------------------------------------------------------------------------
|
||||
#
|
||||
|
||||
if File.expand_path($0) == File.expand_path(__FILE__)
|
||||
inserter = DisplayNameInserter.new(ARGV)
|
||||
inserter.process()
|
||||
end
|
101
utilities/languageSupport/translateDisplayNames/display_name_stripper.rb
Executable file
101
utilities/languageSupport/translateDisplayNames/display_name_stripper.rb
Executable file
|
@ -0,0 +1,101 @@
|
|||
#!/usr/bin/ruby
|
||||
=begin
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
A utility that reads an RDF file, builds a model, sorts all of the URIs that have
|
||||
display_names, and produces a file of those display_names, one per line. The idea is that this
|
||||
file could be translated, and the result could be put into RDF by display_name_inserter.rb
|
||||
|
||||
This required the RDF.rb gem: sudo gem install rdf
|
||||
|
||||
On the command line provide the path to the RDF file. E.g.:
|
||||
|
||||
display_name_stripper.rb '../../PropertyConfig.n3'
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
=end
|
||||
|
||||
$: << File.dirname(File.expand_path(__FILE__))
|
||||
require 'rubygems'
|
||||
require 'rdf'
|
||||
require 'display_name_common'
|
||||
require 'rdf/n3'
|
||||
|
||||
include RDF
|
||||
|
||||
class DisplayNameStripper
|
||||
# ------------------------------------------------------------------------------------
|
||||
private
|
||||
# ------------------------------------------------------------------------------------
|
||||
|
||||
#
|
||||
# Parse the arguments and complain if they don't make sense.
|
||||
#
|
||||
def sanity_check_arguments(args)
|
||||
raise UsageError, "usage is: display_name_stripper.rb <rdf_file> [filter_file] <display_names_output_file> [ok]" unless (2..3).include?(args.length)
|
||||
|
||||
if args[-1].downcase == 'ok'
|
||||
ok = true
|
||||
args.pop
|
||||
else
|
||||
ok = false
|
||||
end
|
||||
|
||||
output_file = args.pop
|
||||
raise UsageError, "File '#{output_file}' already exists. specify 'ok' to overwrite it." if File.exist?(output_file) && !ok
|
||||
|
||||
rdf_file = args[0]
|
||||
raise UsageError, "File '#{rdf_file}' does not exist." unless File.exist?(rdf_file)
|
||||
|
||||
filter_file = args[1]
|
||||
raise UsageError, "File '#{filter_file}' does not exist." if filter_file && !File.exist?(filter_file)
|
||||
filter = DisplayNameCommon.load_filter(filter_file)
|
||||
|
||||
return rdf_file, filter, output_file
|
||||
end
|
||||
|
||||
# ------------------------------------------------------------------------------------
|
||||
public
|
||||
# ------------------------------------------------------------------------------------
|
||||
|
||||
def initialize(args)
|
||||
@rdf_file, @filter, @display_names_output_file = sanity_check_arguments(args)
|
||||
rescue UsageError => e
|
||||
puts "\n----------------\nUsage error\n----------------\n\n#{e}\n\n----------------\n\n"
|
||||
exit
|
||||
rescue FilterError => e
|
||||
puts "\n----------------\nFilter file is invalid\n----------------\n\n#{e}\n\n----------------\n\n"
|
||||
exit
|
||||
end
|
||||
|
||||
def process()
|
||||
query = Query.new({
|
||||
:prop => {
|
||||
DISPLAY_NAME_URI => :display_name,
|
||||
}
|
||||
})
|
||||
|
||||
solutions = DisplayNameCommon.new(@rdf_file).process(query, &@filter)
|
||||
|
||||
File.open(@display_names_output_file, 'w') do |f|
|
||||
solutions.each do |s|
|
||||
f.puts s.display_name
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
#
|
||||
# ------------------------------------------------------------------------------------
|
||||
# Standalone calling.
|
||||
#
|
||||
# Do this if this program was called from the command line. That is, if the command
|
||||
# expands to the path of this file.
|
||||
# ------------------------------------------------------------------------------------
|
||||
#
|
||||
|
||||
if File.expand_path($0) == File.expand_path(__FILE__)
|
||||
stripper = DisplayNameStripper.new(ARGV)
|
||||
stripper.process()
|
||||
end
|
Loading…
Add table
Reference in a new issue