[
  {
    "path": ".editorconfig",
    "content": "# To learn more about .editorconfig see https://aka.ms/editorconfigdocs\n############################### \n# Core EditorConfig Options   # \n############################### \n# All files \n[*]\nindent_style=space\n\n# Code files \n[*.{cs,csx,vb,vbx}]\nindent_size=4\ninsert_final_newline=true\ncharset=utf-8\n############################### \n# .NET Coding Conventions     # \n############################### \n[*.{cs,vb}]\n# Organize usings \ndotnet_sort_system_directives_first=true\n# this. preferences \ndotnet_style_qualification_for_field=false:silent\ndotnet_style_qualification_for_property=false:silent\ndotnet_style_qualification_for_method=false:silent\ndotnet_style_qualification_for_event=false:silent\n# Language keywords vs BCL types preferences \ndotnet_style_predefined_type_for_locals_parameters_members=true:silent\ndotnet_style_predefined_type_for_member_access=true:silent\n# Parentheses preferences \ndotnet_style_parentheses_in_arithmetic_binary_operators=always_for_clarity:silent\ndotnet_style_parentheses_in_relational_binary_operators=always_for_clarity:silent\ndotnet_style_parentheses_in_other_binary_operators=always_for_clarity:silent\ndotnet_style_parentheses_in_other_operators=never_if_unnecessary:silent\n# Modifier preferences \ndotnet_style_require_accessibility_modifiers=for_non_interface_members:silent\ndotnet_style_readonly_field=true:suggestion\n# Expression-level preferences \ndotnet_style_object_initializer=true:suggestion\ndotnet_style_collection_initializer=true:suggestion\ndotnet_style_explicit_tuple_names=true:suggestion\ndotnet_style_null_propagation=true:suggestion\ndotnet_style_coalesce_expression=true:suggestion\ndotnet_style_prefer_is_null_check_over_reference_equality_method=true:silent\ndotnet_prefer_inferred_tuple_names=true:suggestion\ndotnet_prefer_inferred_anonymous_type_member_names=true:suggestion\ndotnet_style_prefer_auto_properties=true:silent\ndotnet_style_prefer_conditional_expression_over_assignment=true:silent\ndotnet_style_prefer_conditional_expression_over_return=true:silent\n############################### \n# Naming Conventions          # \n############################### \n# Style Definitions \ndotnet_naming_style.pascal_case_style.capitalization=pascal_case\n# Use PascalCase for constant fields   \ndotnet_naming_rule.constant_fields_should_be_pascal_case.severity=suggestion\ndotnet_naming_rule.constant_fields_should_be_pascal_case.symbols=constant_fields\ndotnet_naming_rule.constant_fields_should_be_pascal_case.style=pascal_case_style\ndotnet_naming_symbols.constant_fields.applicable_kinds=field\ndotnet_naming_symbols.constant_fields.applicable_accessibilities=*\ndotnet_naming_symbols.constant_fields.required_modifiers=const\n############################### \n# C# Coding Conventions       # \n############################### \n[*.cs]\n# var preferences \ncsharp_style_var_for_built_in_types=true:silent\ncsharp_style_var_when_type_is_apparent=true:silent\ncsharp_style_var_elsewhere=true:silent\n# Expression-bodied members \ncsharp_style_expression_bodied_methods=false:silent\ncsharp_style_expression_bodied_constructors=false:silent\ncsharp_style_expression_bodied_operators=false:silent\ncsharp_style_expression_bodied_properties=true:silent\ncsharp_style_expression_bodied_indexers=true:silent\ncsharp_style_expression_bodied_accessors=true:silent\n# Pattern matching preferences \ncsharp_style_pattern_matching_over_is_with_cast_check=true:suggestion\ncsharp_style_pattern_matching_over_as_with_null_check=true:suggestion\n# Null-checking preferences \ncsharp_style_throw_expression=true:suggestion\ncsharp_style_conditional_delegate_call=true:suggestion\n# Modifier preferences \ncsharp_preferred_modifier_order=public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:suggestion\n# Expression-level preferences \ncsharp_prefer_braces=true:silent\ncsharp_style_deconstructed_variable_declaration=true:suggestion\ncsharp_prefer_simple_default_expression=true:suggestion\ncsharp_style_pattern_local_over_anonymous_function=true:suggestion\ncsharp_style_inlined_variable_declaration=true:suggestion\ncsharp_using_directive_placement=outside_namespace:silent\n############################### \n# C# Formatting Rules         # \n############################### \n# New line preferences \ncsharp_new_line_before_open_brace=all\ncsharp_new_line_before_else=true\ncsharp_new_line_before_catch=true\ncsharp_new_line_before_finally=true\ncsharp_new_line_before_members_in_object_initializers=true\ncsharp_new_line_before_members_in_anonymous_types=true\ncsharp_new_line_between_query_expression_clauses=true\n# Indentation preferences \ncsharp_indent_case_contents=true\ncsharp_indent_switch_labels=true\ncsharp_indent_labels=flush_left\ncsharp_indent_braces=false\n# Space preferences \ncsharp_space_after_cast=false\ncsharp_space_after_keywords_in_control_flow_statements=true\ncsharp_space_between_method_call_parameter_list_parentheses=false\ncsharp_space_between_method_declaration_parameter_list_parentheses=false\ncsharp_space_between_parentheses=false\ncsharp_space_before_colon_in_inheritance_clause=true\ncsharp_space_after_colon_in_inheritance_clause=true\ncsharp_space_around_binary_operators=before_and_after\ncsharp_space_between_method_declaration_empty_parameter_list_parentheses=false\ncsharp_space_between_method_call_name_and_opening_parenthesis=false\ncsharp_space_between_method_call_empty_parameter_list_parentheses=false\n# Wrapping preferences \ncsharp_preserve_single_line_statements=true\ncsharp_preserve_single_line_blocks=true\n############################### \n# ReSharper Rules             # \n############################### \n# ReSharper properties\nresharper_align_linq_query=true\nresharper_align_multiline_argument=true\nresharper_align_multiline_calls_chain=true\nresharper_align_multiline_extends_list=true\nresharper_align_multline_type_parameter_constrains=true\nresharper_align_multline_type_parameter_list=true\nresharper_align_tuple_components=true\nresharper_blank_lines_before_single_line_comment=1\nresharper_csharp_align_multiline_parameter=true\nresharper_csharp_align_multiple_declaration=true\nresharper_csharp_empty_block_style=together\nresharper_csharp_insert_final_newline=true\nresharper_csharp_use_indent_from_vs=false\nresharper_keep_existing_declaration_block_arrangement=false\nresharper_keep_existing_switch_expression_arrangement=false\nresharper_max_enum_members_on_line=1\nresharper_max_initializer_elements_on_line=1\nresharper_place_simple_anonymousmethod_on_single_line=false\nresharper_place_simple_embedded_statement_on_same_line=False\nresharper_place_simple_initializer_on_single_line=true\nresharper_wrap_linq_expressions=chop_always\n"
  },
  {
    "path": ".gitattributes",
    "content": "###############################################################################\n# Set default behavior to automatically normalize line endings.\n###############################################################################\n* text=auto\n\n###############################################################################\n# Set default behavior for command prompt diff.\n#\n# This is need for earlier builds of msysgit that does not have it on by\n# default for csharp files.\n# Note: This is only used by command line\n###############################################################################\n#*.cs     diff=csharp\n\n###############################################################################\n# Set the merge driver for project and solution files\n#\n# Merging from the command prompt will add diff markers to the files if there\n# are conflicts (Merging from VS is not affected by the settings below, in VS\n# the diff markers are never inserted). Diff markers may cause the following \n# file extensions to fail to load in VS. An alternative would be to treat\n# these files as binary and thus will always conflict and require user\n# intervention with every merge. To do so, just uncomment the entries below\n###############################################################################\n#*.sln       merge=binary\n#*.csproj    merge=binary\n#*.vbproj    merge=binary\n#*.vcxproj   merge=binary\n#*.vcproj    merge=binary\n#*.dbproj    merge=binary\n#*.fsproj    merge=binary\n#*.lsproj    merge=binary\n#*.wixproj   merge=binary\n#*.modelproj merge=binary\n#*.sqlproj   merge=binary\n#*.wwaproj   merge=binary\n\n###############################################################################\n# behavior for image files\n#\n# image files are treated as binary by default.\n###############################################################################\n#*.jpg   binary\n#*.png   binary\n#*.gif   binary\n\n###############################################################################\n# diff behavior for common document formats\n# \n# Convert binary document formats to text before diffing them. This feature\n# is only available from the command line. Turn it on by uncommenting the \n# entries below.\n###############################################################################\n#*.doc   diff=astextplain\n#*.DOC   diff=astextplain\n#*.docx  diff=astextplain\n#*.DOCX  diff=astextplain\n#*.dot   diff=astextplain\n#*.DOT   diff=astextplain\n#*.pdf   diff=astextplain\n#*.PDF   diff=astextplain\n#*.rtf   diff=astextplain\n#*.RTF   diff=astextplain\n"
  },
  {
    "path": ".github/workflows/build.yml",
    "content": "name: Mod Build\n\non: [push]\n\njobs:\n  build:\n    runs-on: windows-latest\n    steps:\n      - uses: actions/checkout@v1\n        with:\n          submodules: recursive\n\n      - name: Installer NuGet client\n        uses: nuget/setup-nuget@v1\n\n      - name: Setup tModLoader\n        uses: chi-rei-den/ModLoaderTools@v1.1\n        with:\n          command: setup\n\n      - name: Restore NuGet Packages\n        run: nuget restore Localizer.sln\n\n      - name: Build Mod\n        run: |\n          & \"C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\MSBuild\\Current\\Bin\\MSBuild.exe\" Localizer.sln /p:Configuration=Release /p:Platform=x86\n\n      - name: Patch Mod\n        run: '& \"$ENV:GITHUB_WORKSPACE\\ModPatch\\bin\\Release\\net472\\ModPatch.exe\"'\n\n      - name: Publish Mod\n        if: github.ref == 'refs/heads/master'\n        uses: chi-rei-den/ModLoaderTools@v1\n        with:\n          command: publish\n          path: Localizer\n        env:\n          steamid64: ${{ secrets.steamid64 }}\n          passphrase: ${{ secrets.mod_browser_passphrase }}\n\n      - name: Clean artifact\n        run: |\n          mkdir .\\Artifact\\Artifact\\\n          Copy-Item -Path \"$ENV:UserProfile\\Documents\\My Games\\Terraria\\ModLoader\\Mods\\*\" -Destination .\\Artifact\\Artifact\n          del .\\Artifact\\Artifact\\enabled.json\n\n      - uses: actions/upload-artifact@master\n        with:\n          name: Build Artifact\n          path: Artifact\n\n      - name: Run Tests\n        run: |\n          copy .\\LocalizerTest\\bin\\Release\\net472\\tModLoader.exe .\\LocalizerTest\\bin\\Release\\net472\\Terraria.exe\n          & \"$ENV:UserProfile\\.nuget\\packages\\xunit.runner.console\\2.4.1\\tools\\net472\\xunit.console.x86.exe\" \".\\LocalizerTest\\bin\\Release\\net472\\LocalizerTest.dll\""
  },
  {
    "path": ".gitignore",
    "content": "## Ignore Visual Studio temporary files, build results, and\n## files generated by popular Visual Studio add-ons.\n\nLocalizer/WPF/\n\n# User-specific files\n*.suo\n*.user\n*.userosscache\n*.sln.docstates\n\n# User-specific files (MonoDevelop/Xamarin Studio)\n*.userprefs\n\n# Build results\n[Dd]ebug/\n[Dd]ebugPublic/\n[Rr]elease/\n[Rr]eleases/\nx64/\nx86/\nbld/\n[Bb]in/\n[Oo]bj/\n[Ll]og/\n\n# Visual Studio 2015 cache/options directory\n.vs/\n# Uncomment if you have tasks that create the project's static files in wwwroot\n#wwwroot/\n\n# MSTest test Results\n[Tt]est[Rr]esult*/\n[Bb]uild[Ll]og.*\n\n# NUNIT\n*.VisualState.xml\nTestResult.xml\n\n# Build Results of an ATL Project\n[Dd]ebugPS/\n[Rr]eleasePS/\ndlldata.c\n\n# DNX\nproject.lock.json\nproject.fragment.lock.json\nartifacts/\n\n*_i.c\n*_p.c\n*_i.h\n*.ilk\n*.meta\n*.obj\n*.pch\n*.pdb\n*.pgc\n*.pgd\n*.rsp\n*.sbr\n*.tlb\n*.tli\n*.tlh\n*.tmp\n*.tmp_proj\n*.log\n*.vspscc\n*.vssscc\n.builds\n*.pidb\n*.svclog\n*.scc\n\n# Chutzpah Test files\n_Chutzpah*\n\n# Visual C++ cache files\nipch/\n*.aps\n*.ncb\n*.opendb\n*.opensdf\n*.sdf\n*.cachefile\n*.VC.db\n*.VC.VC.opendb\n\n# Visual Studio profiler\n*.psess\n*.vsp\n*.vspx\n*.sap\n\n# TFS 2012 Local Workspace\n$tf/\n\n# Guidance Automation Toolkit\n*.gpState\n\n# ReSharper is a .NET coding add-in\n_ReSharper*/\n*.[Rr]e[Ss]harper\n*.DotSettings.user\n\n# JustCode is a .NET coding add-in\n.JustCode\n\n# TeamCity is a build add-in\n_TeamCity*\n\n# DotCover is a Code Coverage Tool\n*.dotCover\n\n# NCrunch\n_NCrunch_*\n.*crunch*.local.xml\nnCrunchTemp_*\n\n# MightyMoose\n*.mm.*\nAutoTest.Net/\n\n# Web workbench (sass)\n.sass-cache/\n\n# Installshield output folder\n[Ee]xpress/\n\n# DocProject is a documentation generator add-in\nDocProject/buildhelp/\nDocProject/Help/*.HxT\nDocProject/Help/*.HxC\nDocProject/Help/*.hhc\nDocProject/Help/*.hhk\nDocProject/Help/*.hhp\nDocProject/Help/Html2\nDocProject/Help/html\n\n# Click-Once directory\npublish/\n\n# Publish Web Output\n*.[Pp]ublish.xml\n*.azurePubxml\n# TODO: Comment the next line if you want to checkin your web deploy settings\n# but database connection strings (with potential passwords) will be unencrypted\n#*.pubxml\n*.publishproj\n\n# Microsoft Azure Web App publish settings. Comment the next line if you want to\n# checkin your Azure Web App publish settings, but sensitive information contained\n# in these scripts will be unencrypted\nPublishScripts/\n\n# NuGet Packages\n*.nupkg\n# The packages folder can be ignored because of Package Restore\n**/packages/*\n# except build/, which is used as an MSBuild target.\n!**/packages/build/\n# Uncomment if necessary however generally it will be regenerated when needed\n#!**/packages/repositories.config\n# NuGet v3's project.json files produces more ignoreable files\n*.nuget.props\n*.nuget.targets\n\n# Microsoft Azure Build Output\ncsx/\n*.build.csdef\n\n# Microsoft Azure Emulator\necf/\nrcf/\n\n# Windows Store app package directories and files\nAppPackages/\nBundleArtifacts/\nPackage.StoreAssociation.xml\n_pkginfo.txt\n\n# Visual Studio cache files\n# files ending in .cache can be ignored\n*.[Cc]ache\n# but keep track of directories ending in .cache\n!*.[Cc]ache/\n\n# Others\nClientBin/\n~$*\n*~\n*.dbmdl\n*.dbproj.schemaview\n*.jfm\n*.pfx\n*.publishsettings\nnode_modules/\norleans.codegen.cs\n\n# Since there are multiple workflows, uncomment next line to ignore bower_components\n# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)\n#bower_components/\n\n# RIA/Silverlight projects\nGenerated_Code/\n\n# Backup & report files from converting an old project file\n# to a newer Visual Studio version. Backup files are not needed,\n# because we have git ;-)\n_UpgradeReport_Files/\nBackup*/\nUpgradeLog*.XML\nUpgradeLog*.htm\n\n# SQL Server files\n*.mdf\n*.ldf\n\n# Business Intelligence projects\n*.rdl.data\n*.bim.layout\n*.bim_*.settings\n\n# Microsoft Fakes\nFakesAssemblies/\n\n# GhostDoc plugin setting file\n*.GhostDoc.xml\n\n# Node.js Tools for Visual Studio\n.ntvs_analysis.dat\n\n# Visual Studio 6 build log\n*.plg\n\n# Visual Studio 6 workspace options file\n*.opt\n\n# Visual Studio LightSwitch build output\n**/*.HTMLClient/GeneratedArtifacts\n**/*.DesktopClient/GeneratedArtifacts\n**/*.DesktopClient/ModelManifest.xml\n**/*.Server/GeneratedArtifacts\n**/*.Server/ModelManifest.xml\n_Pvt_Extensions\n\n# Paket dependency manager\n.paket/paket.exe\npaket-files/\n\n# FAKE - F# Make\n.fake/\n\n# JetBrains Rider\n.idea/\n*.sln.iml\n\n# CodeRush\n.cr/\n\n# Python Tools for Visual Studio (PTVS)\n__pycache__/\n*.pyc\n\n/Localizer/Plugins\n/Localizer/lib\n"
  },
  {
    "path": ".gitmodules",
    "content": "[submodule \"Squid\"]\n\tpath = Squid\n\turl = https://github.com/chi-rei-den/Squid\n"
  },
  {
    "path": "LICENSE",
    "content": "                    GNU GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 2007\n\n Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n                            Preamble\n\n  The GNU General Public License is a free, copyleft license for\nsoftware and other kinds of works.\n\n  The licenses for most software and other practical works are designed\nto take away your freedom to share and change the works.  By contrast,\nthe GNU General Public License is intended to guarantee your freedom to\nshare and change all versions of a program--to make sure it remains free\nsoftware for all its users.  We, the Free Software Foundation, use the\nGNU General Public License for most of our software; it applies also to\nany other work released this way by its authors.  You can apply it to\nyour programs, too.\n\n  When we speak of free software, we are referring to freedom, not\nprice.  Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthem if you wish), that you receive source code or can get it if you\nwant it, that you can change the software or use pieces of it in new\nfree programs, and that you know you can do these things.\n\n  To protect your rights, we need to prevent others from denying you\nthese rights or asking you to surrender the rights.  Therefore, you have\ncertain responsibilities if you distribute copies of the software, or if\nyou modify it: responsibilities to respect the freedom of others.\n\n  For example, if you distribute copies of such a program, whether\ngratis or for a fee, you must pass on to the recipients the same\nfreedoms that you received.  You must make sure that they, too, receive\nor can get the source code.  And you must show them these terms so they\nknow their rights.\n\n  Developers that use the GNU GPL protect your rights with two steps:\n(1) assert copyright on the software, and (2) offer you this License\ngiving you legal permission to copy, distribute and/or modify it.\n\n  For the developers' and authors' protection, the GPL clearly explains\nthat there is no warranty for this free software.  For both users' and\nauthors' sake, the GPL requires that modified versions be marked as\nchanged, so that their problems will not be attributed erroneously to\nauthors of previous versions.\n\n  Some devices are designed to deny users access to install or run\nmodified versions of the software inside them, although the manufacturer\ncan do so.  This is fundamentally incompatible with the aim of\nprotecting users' freedom to change the software.  The systematic\npattern of such abuse occurs in the area of products for individuals to\nuse, which is precisely where it is most unacceptable.  Therefore, we\nhave designed this version of the GPL to prohibit the practice for those\nproducts.  If such problems arise substantially in other domains, we\nstand ready to extend this provision to those domains in future versions\nof the GPL, as needed to protect the freedom of users.\n\n  Finally, every program is threatened constantly by software patents.\nStates should not allow patents to restrict development and use of\nsoftware on general-purpose computers, but in those that do, we wish to\navoid the special danger that patents applied to a free program could\nmake it effectively proprietary.  To prevent this, the GPL assures that\npatents cannot be used to render the program non-free.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.\n\n                       TERMS AND CONDITIONS\n\n  0. Definitions.\n\n  \"This License\" refers to version 3 of the GNU General Public License.\n\n  \"Copyright\" also means copyright-like laws that apply to other kinds of\nworks, such as semiconductor masks.\n\n  \"The Program\" refers to any copyrightable work licensed under this\nLicense.  Each licensee is addressed as \"you\".  \"Licensees\" and\n\"recipients\" may be individuals or organizations.\n\n  To \"modify\" a work means to copy from or adapt all or part of the work\nin a fashion requiring copyright permission, other than the making of an\nexact copy.  The resulting work is called a \"modified version\" of the\nearlier work or a work \"based on\" the earlier work.\n\n  A \"covered work\" means either the unmodified Program or a work based\non the Program.\n\n  To \"propagate\" a work means to do anything with it that, without\npermission, would make you directly or secondarily liable for\ninfringement under applicable copyright law, except executing it on a\ncomputer or modifying a private copy.  Propagation includes copying,\ndistribution (with or without modification), making available to the\npublic, and in some countries other activities as well.\n\n  To \"convey\" a work means any kind of propagation that enables other\nparties to make or receive copies.  Mere interaction with a user through\na computer network, with no transfer of a copy, is not conveying.\n\n  An interactive user interface displays \"Appropriate Legal Notices\"\nto the extent that it includes a convenient and prominently visible\nfeature that (1) displays an appropriate copyright notice, and (2)\ntells the user that there is no warranty for the work (except to the\nextent that warranties are provided), that licensees may convey the\nwork under this License, and how to view a copy of this License.  If\nthe interface presents a list of user commands or options, such as a\nmenu, a prominent item in the list meets this criterion.\n\n  1. Source Code.\n\n  The \"source code\" for a work means the preferred form of the work\nfor making modifications to it.  \"Object code\" means any non-source\nform of a work.\n\n  A \"Standard Interface\" means an interface that either is an official\nstandard defined by a recognized standards body, or, in the case of\ninterfaces specified for a particular programming language, one that\nis widely used among developers working in that language.\n\n  The \"System Libraries\" of an executable work include anything, other\nthan the work as a whole, that (a) is included in the normal form of\npackaging a Major Component, but which is not part of that Major\nComponent, and (b) serves only to enable use of the work with that\nMajor Component, or to implement a Standard Interface for which an\nimplementation is available to the public in source code form.  A\n\"Major Component\", in this context, means a major essential component\n(kernel, window system, and so on) of the specific operating system\n(if any) on which the executable work runs, or a compiler used to\nproduce the work, or an object code interpreter used to run it.\n\n  The \"Corresponding Source\" for a work in object code form means all\nthe source code needed to generate, install, and (for an executable\nwork) run the object code and to modify the work, including scripts to\ncontrol those activities.  However, it does not include the work's\nSystem Libraries, or general-purpose tools or generally available free\nprograms which are used unmodified in performing those activities but\nwhich are not part of the work.  For example, Corresponding Source\nincludes interface definition files associated with source files for\nthe work, and the source code for shared libraries and dynamically\nlinked subprograms that the work is specifically designed to require,\nsuch as by intimate data communication or control flow between those\nsubprograms and other parts of the work.\n\n  The Corresponding Source need not include anything that users\ncan regenerate automatically from other parts of the Corresponding\nSource.\n\n  The Corresponding Source for a work in source code form is that\nsame work.\n\n  2. Basic Permissions.\n\n  All rights granted under this License are granted for the term of\ncopyright on the Program, and are irrevocable provided the stated\nconditions are met.  This License explicitly affirms your unlimited\npermission to run the unmodified Program.  The output from running a\ncovered work is covered by this License only if the output, given its\ncontent, constitutes a covered work.  This License acknowledges your\nrights of fair use or other equivalent, as provided by copyright law.\n\n  You may make, run and propagate covered works that you do not\nconvey, without conditions so long as your license otherwise remains\nin force.  You may convey covered works to others for the sole purpose\nof having them make modifications exclusively for you, or provide you\nwith facilities for running those works, provided that you comply with\nthe terms of this License in conveying all material for which you do\nnot control copyright.  Those thus making or running the covered works\nfor you must do so exclusively on your behalf, under your direction\nand control, on terms that prohibit them from making any copies of\nyour copyrighted material outside their relationship with you.\n\n  Conveying under any other circumstances is permitted solely under\nthe conditions stated below.  Sublicensing is not allowed; section 10\nmakes it unnecessary.\n\n  3. Protecting Users' Legal Rights From Anti-Circumvention Law.\n\n  No covered work shall be deemed part of an effective technological\nmeasure under any applicable law fulfilling obligations under article\n11 of the WIPO copyright treaty adopted on 20 December 1996, or\nsimilar laws prohibiting or restricting circumvention of such\nmeasures.\n\n  When you convey a covered work, you waive any legal power to forbid\ncircumvention of technological measures to the extent such circumvention\nis effected by exercising rights under this License with respect to\nthe covered work, and you disclaim any intention to limit operation or\nmodification of the work as a means of enforcing, against the work's\nusers, your or third parties' legal rights to forbid circumvention of\ntechnological measures.\n\n  4. Conveying Verbatim Copies.\n\n  You may convey verbatim copies of the Program's source code as you\nreceive it, in any medium, provided that you conspicuously and\nappropriately publish on each copy an appropriate copyright notice;\nkeep intact all notices stating that this License and any\nnon-permissive terms added in accord with section 7 apply to the code;\nkeep intact all notices of the absence of any warranty; and give all\nrecipients a copy of this License along with the Program.\n\n  You may charge any price or no price for each copy that you convey,\nand you may offer support or warranty protection for a fee.\n\n  5. Conveying Modified Source Versions.\n\n  You may convey a work based on the Program, or the modifications to\nproduce it from the Program, in the form of source code under the\nterms of section 4, provided that you also meet all of these conditions:\n\n    a) The work must carry prominent notices stating that you modified\n    it, and giving a relevant date.\n\n    b) The work must carry prominent notices stating that it is\n    released under this License and any conditions added under section\n    7.  This requirement modifies the requirement in section 4 to\n    \"keep intact all notices\".\n\n    c) You must license the entire work, as a whole, under this\n    License to anyone who comes into possession of a copy.  This\n    License will therefore apply, along with any applicable section 7\n    additional terms, to the whole of the work, and all its parts,\n    regardless of how they are packaged.  This License gives no\n    permission to license the work in any other way, but it does not\n    invalidate such permission if you have separately received it.\n\n    d) If the work has interactive user interfaces, each must display\n    Appropriate Legal Notices; however, if the Program has interactive\n    interfaces that do not display Appropriate Legal Notices, your\n    work need not make them do so.\n\n  A compilation of a covered work with other separate and independent\nworks, which are not by their nature extensions of the covered work,\nand which are not combined with it such as to form a larger program,\nin or on a volume of a storage or distribution medium, is called an\n\"aggregate\" if the compilation and its resulting copyright are not\nused to limit the access or legal rights of the compilation's users\nbeyond what the individual works permit.  Inclusion of a covered work\nin an aggregate does not cause this License to apply to the other\nparts of the aggregate.\n\n  6. Conveying Non-Source Forms.\n\n  You may convey a covered work in object code form under the terms\nof sections 4 and 5, provided that you also convey the\nmachine-readable Corresponding Source under the terms of this License,\nin one of these ways:\n\n    a) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by the\n    Corresponding Source fixed on a durable physical medium\n    customarily used for software interchange.\n\n    b) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by a\n    written offer, valid for at least three years and valid for as\n    long as you offer spare parts or customer support for that product\n    model, to give anyone who possesses the object code either (1) a\n    copy of the Corresponding Source for all the software in the\n    product that is covered by this License, on a durable physical\n    medium customarily used for software interchange, for a price no\n    more than your reasonable cost of physically performing this\n    conveying of source, or (2) access to copy the\n    Corresponding Source from a network server at no charge.\n\n    c) Convey individual copies of the object code with a copy of the\n    written offer to provide the Corresponding Source.  This\n    alternative is allowed only occasionally and noncommercially, and\n    only if you received the object code with such an offer, in accord\n    with subsection 6b.\n\n    d) Convey the object code by offering access from a designated\n    place (gratis or for a charge), and offer equivalent access to the\n    Corresponding Source in the same way through the same place at no\n    further charge.  You need not require recipients to copy the\n    Corresponding Source along with the object code.  If the place to\n    copy the object code is a network server, the Corresponding Source\n    may be on a different server (operated by you or a third party)\n    that supports equivalent copying facilities, provided you maintain\n    clear directions next to the object code saying where to find the\n    Corresponding Source.  Regardless of what server hosts the\n    Corresponding Source, you remain obligated to ensure that it is\n    available for as long as needed to satisfy these requirements.\n\n    e) Convey the object code using peer-to-peer transmission, provided\n    you inform other peers where the object code and Corresponding\n    Source of the work are being offered to the general public at no\n    charge under subsection 6d.\n\n  A separable portion of the object code, whose source code is excluded\nfrom the Corresponding Source as a System Library, need not be\nincluded in conveying the object code work.\n\n  A \"User Product\" is either (1) a \"consumer product\", which means any\ntangible personal property which is normally used for personal, family,\nor household purposes, or (2) anything designed or sold for incorporation\ninto a dwelling.  In determining whether a product is a consumer product,\ndoubtful cases shall be resolved in favor of coverage.  For a particular\nproduct received by a particular user, \"normally used\" refers to a\ntypical or common use of that class of product, regardless of the status\nof the particular user or of the way in which the particular user\nactually uses, or expects or is expected to use, the product.  A product\nis a consumer product regardless of whether the product has substantial\ncommercial, industrial or non-consumer uses, unless such uses represent\nthe only significant mode of use of the product.\n\n  \"Installation Information\" for a User Product means any methods,\nprocedures, authorization keys, or other information required to install\nand execute modified versions of a covered work in that User Product from\na modified version of its Corresponding Source.  The information must\nsuffice to ensure that the continued functioning of the modified object\ncode is in no case prevented or interfered with solely because\nmodification has been made.\n\n  If you convey an object code work under this section in, or with, or\nspecifically for use in, a User Product, and the conveying occurs as\npart of a transaction in which the right of possession and use of the\nUser Product is transferred to the recipient in perpetuity or for a\nfixed term (regardless of how the transaction is characterized), the\nCorresponding Source conveyed under this section must be accompanied\nby the Installation Information.  But this requirement does not apply\nif neither you nor any third party retains the ability to install\nmodified object code on the User Product (for example, the work has\nbeen installed in ROM).\n\n  The requirement to provide Installation Information does not include a\nrequirement to continue to provide support service, warranty, or updates\nfor a work that has been modified or installed by the recipient, or for\nthe User Product in which it has been modified or installed.  Access to a\nnetwork may be denied when the modification itself materially and\nadversely affects the operation of the network or violates the rules and\nprotocols for communication across the network.\n\n  Corresponding Source conveyed, and Installation Information provided,\nin accord with this section must be in a format that is publicly\ndocumented (and with an implementation available to the public in\nsource code form), and must require no special password or key for\nunpacking, reading or copying.\n\n  7. Additional Terms.\n\n  \"Additional permissions\" are terms that supplement the terms of this\nLicense by making exceptions from one or more of its conditions.\nAdditional permissions that are applicable to the entire Program shall\nbe treated as though they were included in this License, to the extent\nthat they are valid under applicable law.  If additional permissions\napply only to part of the Program, that part may be used separately\nunder those permissions, but the entire Program remains governed by\nthis License without regard to the additional permissions.\n\n  When you convey a copy of a covered work, you may at your option\nremove any additional permissions from that copy, or from any part of\nit.  (Additional permissions may be written to require their own\nremoval in certain cases when you modify the work.)  You may place\nadditional permissions on material, added by you to a covered work,\nfor which you have or can give appropriate copyright permission.\n\n  Notwithstanding any other provision of this License, for material you\nadd to a covered work, you may (if authorized by the copyright holders of\nthat material) supplement the terms of this License with terms:\n\n    a) Disclaiming warranty or limiting liability differently from the\n    terms of sections 15 and 16 of this License; or\n\n    b) Requiring preservation of specified reasonable legal notices or\n    author attributions in that material or in the Appropriate Legal\n    Notices displayed by works containing it; or\n\n    c) Prohibiting misrepresentation of the origin of that material, or\n    requiring that modified versions of such material be marked in\n    reasonable ways as different from the original version; or\n\n    d) Limiting the use for publicity purposes of names of licensors or\n    authors of the material; or\n\n    e) Declining to grant rights under trademark law for use of some\n    trade names, trademarks, or service marks; or\n\n    f) Requiring indemnification of licensors and authors of that\n    material by anyone who conveys the material (or modified versions of\n    it) with contractual assumptions of liability to the recipient, for\n    any liability that these contractual assumptions directly impose on\n    those licensors and authors.\n\n  All other non-permissive additional terms are considered \"further\nrestrictions\" within the meaning of section 10.  If the Program as you\nreceived it, or any part of it, contains a notice stating that it is\ngoverned by this License along with a term that is a further\nrestriction, you may remove that term.  If a license document contains\na further restriction but permits relicensing or conveying under this\nLicense, you may add to a covered work material governed by the terms\nof that license document, provided that the further restriction does\nnot survive such relicensing or conveying.\n\n  If you add terms to a covered work in accord with this section, you\nmust place, in the relevant source files, a statement of the\nadditional terms that apply to those files, or a notice indicating\nwhere to find the applicable terms.\n\n  Additional terms, permissive or non-permissive, may be stated in the\nform of a separately written license, or stated as exceptions;\nthe above requirements apply either way.\n\n  8. Termination.\n\n  You may not propagate or modify a covered work except as expressly\nprovided under this License.  Any attempt otherwise to propagate or\nmodify it is void, and will automatically terminate your rights under\nthis License (including any patent licenses granted under the third\nparagraph of section 11).\n\n  However, if you cease all violation of this License, then your\nlicense from a particular copyright holder is reinstated (a)\nprovisionally, unless and until the copyright holder explicitly and\nfinally terminates your license, and (b) permanently, if the copyright\nholder fails to notify you of the violation by some reasonable means\nprior to 60 days after the cessation.\n\n  Moreover, your license from a particular copyright holder is\nreinstated permanently if the copyright holder notifies you of the\nviolation by some reasonable means, this is the first time you have\nreceived notice of violation of this License (for any work) from that\ncopyright holder, and you cure the violation prior to 30 days after\nyour receipt of the notice.\n\n  Termination of your rights under this section does not terminate the\nlicenses of parties who have received copies or rights from you under\nthis License.  If your rights have been terminated and not permanently\nreinstated, you do not qualify to receive new licenses for the same\nmaterial under section 10.\n\n  9. Acceptance Not Required for Having Copies.\n\n  You are not required to accept this License in order to receive or\nrun a copy of the Program.  Ancillary propagation of a covered work\noccurring solely as a consequence of using peer-to-peer transmission\nto receive a copy likewise does not require acceptance.  However,\nnothing other than this License grants you permission to propagate or\nmodify any covered work.  These actions infringe copyright if you do\nnot accept this License.  Therefore, by modifying or propagating a\ncovered work, you indicate your acceptance of this License to do so.\n\n  10. Automatic Licensing of Downstream Recipients.\n\n  Each time you convey a covered work, the recipient automatically\nreceives a license from the original licensors, to run, modify and\npropagate that work, subject to this License.  You are not responsible\nfor enforcing compliance by third parties with this License.\n\n  An \"entity transaction\" is a transaction transferring control of an\norganization, or substantially all assets of one, or subdividing an\norganization, or merging organizations.  If propagation of a covered\nwork results from an entity transaction, each party to that\ntransaction who receives a copy of the work also receives whatever\nlicenses to the work the party's predecessor in interest had or could\ngive under the previous paragraph, plus a right to possession of the\nCorresponding Source of the work from the predecessor in interest, if\nthe predecessor has it or can get it with reasonable efforts.\n\n  You may not impose any further restrictions on the exercise of the\nrights granted or affirmed under this License.  For example, you may\nnot impose a license fee, royalty, or other charge for exercise of\nrights granted under this License, and you may not initiate litigation\n(including a cross-claim or counterclaim in a lawsuit) alleging that\nany patent claim is infringed by making, using, selling, offering for\nsale, or importing the Program or any portion of it.\n\n  11. Patents.\n\n  A \"contributor\" is a copyright holder who authorizes use under this\nLicense of the Program or a work on which the Program is based.  The\nwork thus licensed is called the contributor's \"contributor version\".\n\n  A contributor's \"essential patent claims\" are all patent claims\nowned or controlled by the contributor, whether already acquired or\nhereafter acquired, that would be infringed by some manner, permitted\nby this License, of making, using, or selling its contributor version,\nbut do not include claims that would be infringed only as a\nconsequence of further modification of the contributor version.  For\npurposes of this definition, \"control\" includes the right to grant\npatent sublicenses in a manner consistent with the requirements of\nthis License.\n\n  Each contributor grants you a non-exclusive, worldwide, royalty-free\npatent license under the contributor's essential patent claims, to\nmake, use, sell, offer for sale, import and otherwise run, modify and\npropagate the contents of its contributor version.\n\n  In the following three paragraphs, a \"patent license\" is any express\nagreement or commitment, however denominated, not to enforce a patent\n(such as an express permission to practice a patent or covenant not to\nsue for patent infringement).  To \"grant\" such a patent license to a\nparty means to make such an agreement or commitment not to enforce a\npatent against the party.\n\n  If you convey a covered work, knowingly relying on a patent license,\nand the Corresponding Source of the work is not available for anyone\nto copy, free of charge and under the terms of this License, through a\npublicly available network server or other readily accessible means,\nthen you must either (1) cause the Corresponding Source to be so\navailable, or (2) arrange to deprive yourself of the benefit of the\npatent license for this particular work, or (3) arrange, in a manner\nconsistent with the requirements of this License, to extend the patent\nlicense to downstream recipients.  \"Knowingly relying\" means you have\nactual knowledge that, but for the patent license, your conveying the\ncovered work in a country, or your recipient's use of the covered work\nin a country, would infringe one or more identifiable patents in that\ncountry that you have reason to believe are valid.\n\n  If, pursuant to or in connection with a single transaction or\narrangement, you convey, or propagate by procuring conveyance of, a\ncovered work, and grant a patent license to some of the parties\nreceiving the covered work authorizing them to use, propagate, modify\nor convey a specific copy of the covered work, then the patent license\nyou grant is automatically extended to all recipients of the covered\nwork and works based on it.\n\n  A patent license is \"discriminatory\" if it does not include within\nthe scope of its coverage, prohibits the exercise of, or is\nconditioned on the non-exercise of one or more of the rights that are\nspecifically granted under this License.  You may not convey a covered\nwork if you are a party to an arrangement with a third party that is\nin the business of distributing software, under which you make payment\nto the third party based on the extent of your activity of conveying\nthe work, and under which the third party grants, to any of the\nparties who would receive the covered work from you, a discriminatory\npatent license (a) in connection with copies of the covered work\nconveyed by you (or copies made from those copies), or (b) primarily\nfor and in connection with specific products or compilations that\ncontain the covered work, unless you entered into that arrangement,\nor that patent license was granted, prior to 28 March 2007.\n\n  Nothing in this License shall be construed as excluding or limiting\nany implied license or other defenses to infringement that may\notherwise be available to you under applicable patent law.\n\n  12. No Surrender of Others' Freedom.\n\n  If conditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot convey a\ncovered work so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you may\nnot convey it at all.  For example, if you agree to terms that obligate you\nto collect a royalty for further conveying from those to whom you convey\nthe Program, the only way you could satisfy both those terms and this\nLicense would be to refrain entirely from conveying the Program.\n\n  13. Use with the GNU Affero General Public License.\n\n  Notwithstanding any other provision of this License, you have\npermission to link or combine any covered work with a work licensed\nunder version 3 of the GNU Affero General Public License into a single\ncombined work, and to convey the resulting work.  The terms of this\nLicense will continue to apply to the part which is the covered work,\nbut the special requirements of the GNU Affero General Public License,\nsection 13, concerning interaction through a network will apply to the\ncombination as such.\n\n  14. Revised Versions of this License.\n\n  The Free Software Foundation may publish revised and/or new versions of\nthe GNU General Public License from time to time.  Such new versions will\nbe similar in spirit to the present version, but may differ in detail to\naddress new problems or concerns.\n\n  Each version is given a distinguishing version number.  If the\nProgram specifies that a certain numbered version of the GNU General\nPublic License \"or any later version\" applies to it, you have the\noption of following the terms and conditions either of that numbered\nversion or of any later version published by the Free Software\nFoundation.  If the Program does not specify a version number of the\nGNU General Public License, you may choose any version ever published\nby the Free Software Foundation.\n\n  If the Program specifies that a proxy can decide which future\nversions of the GNU General Public License can be used, that proxy's\npublic statement of acceptance of a version permanently authorizes you\nto choose that version for the Program.\n\n  Later license versions may give you additional or different\npermissions.  However, no additional obligations are imposed on any\nauthor or copyright holder as a result of your choosing to follow a\nlater version.\n\n  15. Disclaimer of Warranty.\n\n  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\nAPPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\nHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY\nOF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\nTHE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\nIS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\nALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n  16. Limitation of Liability.\n\n  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\nTHE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\nGENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\nUSE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\nDATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\nPARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\nEVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\nSUCH DAMAGES.\n\n  17. Interpretation of Sections 15 and 16.\n\n  If the disclaimer of warranty and limitation of liability provided\nabove cannot be given local legal effect according to their terms,\nreviewing courts shall apply local law that most closely approximates\nan absolute waiver of all civil liability in connection with the\nProgram, unless a warranty or assumption of liability accompanies a\ncopy of the Program in return for a fee.\n\n                     END OF TERMS AND CONDITIONS\n\n            How to Apply These Terms to Your New Programs\n\n  If you develop a new program, and you want it to be of the greatest\npossible use to the public, the best way to achieve this is to make it\nfree software which everyone can redistribute and change under these terms.\n\n  To do so, attach the following notices to the program.  It is safest\nto attach them to the start of each source file to most effectively\nstate the exclusion of warranty; and each file should have at least\nthe \"copyright\" line and a pointer to where the full notice is found.\n\n    <one line to give the program's name and a brief idea of what it does.>\n    Copyright (C) <year>  <name of author>\n\n    This program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    You should have received a copy of the GNU General Public License\n    along with this program.  If not, see <https://www.gnu.org/licenses/>.\n\nAlso add information on how to contact you by electronic and paper mail.\n\n  If the program does terminal interaction, make it output a short\nnotice like this when it starts in an interactive mode:\n\n    <program>  Copyright (C) <year>  <name of author>\n    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\n    This is free software, and you are welcome to redistribute it\n    under certain conditions; type `show c' for details.\n\nThe hypothetical commands `show w' and `show c' should show the appropriate\nparts of the General Public License.  Of course, your program's commands\nmight be different; for a GUI interface, you would use an \"about box\".\n\n  You should also get your employer (if you work as a programmer) or school,\nif any, to sign a \"copyright disclaimer\" for the program, if necessary.\nFor more information on this, and how to apply and follow the GNU GPL, see\n<https://www.gnu.org/licenses/>.\n\n  The GNU General Public License does not permit incorporating your program\ninto proprietary programs.  If your program is a subroutine library, you\nmay consider it more useful to permit linking proprietary applications with\nthe library.  If this is what you want to do, use the GNU Lesser General\nPublic License instead of this License.  But first, please read\n<https://www.gnu.org/licenses/why-not-lgpl.html>.\n"
  },
  {
    "path": "Localizer/Attributes/ModTranslationOwnerFieldAttribute.cs",
    "content": "using System;\n\nnamespace Localizer.Attributes\n{\n    /// <summary>\n    /// Indicates the field contains objects those have ModTranslations need to be localized.\n    /// </summary>\n    public class ModTranslationOwnerFieldAttribute : Attribute\n    {\n        public ModTranslationOwnerFieldAttribute(string fieldName)\n        {\n            FieldName = fieldName;\n        }\n\n        public string FieldName { get; }\n    }\n}\n"
  },
  {
    "path": "Localizer/Attributes/ModTranslationPropAttribute.cs",
    "content": "using System;\n\nnamespace Localizer.Attributes\n{\n    /// <summary>\n    /// Indicates the name of ModTranslation property.\n    /// </summary>\n    public class ModTranslationPropAttribute : Attribute\n    {\n        public ModTranslationPropAttribute(string propName)\n        {\n            PropName = propName;\n        }\n\n        public string PropName { get; }\n    }\n}\n"
  },
  {
    "path": "Localizer/Attributes/OperationTimingAttribute.cs",
    "content": "using System;\n\nnamespace Localizer.Attributes\n{\n    public class OperationTimingAttribute : Attribute\n    {\n        public OperationTiming Timing { get; }\n\n        public OperationTimingAttribute(OperationTiming timing = OperationTiming.Any)\n        {\n            Timing = timing;\n        }\n    }\n}\n"
  },
  {
    "path": "Localizer/Configuration.cs",
    "content": "namespace Localizer\n{\n    public class Configuration\n    {\n        public bool AutoImport { get; set; } = true;\n\n        public bool ImportLdstr { get; set; } = true;\n\n        public string LdstrImporter { get; set; } = \"Cecil\";\n\n        public bool ImporBasictAfterSetupContent { get; set; } = true;\n\n        public AutoImportType AutoImportType { get; set; } = AutoImportType.All;\n\n        public bool ShowUI { get; set; } = true;\n\n        public LogLevel LogLevel { get; set; } = LogLevel.Info;\n\n        public bool RebuildTooltips { get; set; } = true;\n\n        public bool RebuildTooltipsOnce { get; set; } = true;\n\n        public string[] ModListMirror { get; set; } = new[]\n        {\n            \"mirror.sgkoi.dev\",\n            \"mirror7.sgkoi.dev\",\n            \"mirror8.sgkoi.dev\",\n            \"mirror5.sgkoi.dev\",\n        };\n\n        public string[] ModDownloadMirror { get; set; } = new[]\n        {\n            \"mirror.sgkoi.dev\",\n            \"mirror7.sgkoi.dev\",\n            \"mirror8.sgkoi.dev\",\n            \"mirror5.sgkoi.dev\",\n        };\n\n        public string[] ModDescMirror { get; set; } = new[]\n        {\n            \"mirror.sgkoi.dev\",\n            \"mirror7.sgkoi.dev\",\n            \"mirror8.sgkoi.dev\",\n            \"mirror5.sgkoi.dev\",\n        };\n    }\n}\n"
  },
  {
    "path": "Localizer/DataModel/Default/AttributeFile.cs",
    "content": "using System.Collections.Generic;\nusing System.Linq;\n\nnamespace Localizer.DataModel.Default\n{\n    public class AttributeFile : IFile\n    {\n        public Dictionary<string, BaseEntry> Translations { get; set; } = new Dictionary<string, BaseEntry>();\n\n        public List<string> GetKeys()\n        {\n            return Translations.Keys.ToList();\n        }\n\n        public IEntry GetValue(string key)\n        {\n            return Translations[key];\n        }\n    }\n}\n"
  },
  {
    "path": "Localizer/DataModel/Default/BaseEntry.cs",
    "content": "﻿namespace Localizer.DataModel.Default\n{\n    public class BaseEntry : IEntry\n    {\n        public string Origin { get; set; }\n\n        public string Translation { get; set; }\n\n        public IEntry Clone()\n        {\n            return new BaseEntry\n            {\n                Origin = Origin,\n                Translation = Translation\n            };\n        }\n    }\n}\n"
  },
  {
    "path": "Localizer/DataModel/Default/BasicBuffFile.cs",
    "content": "﻿using System.Collections.Generic;\nusing System.Linq;\nusing Localizer.Attributes;\n\nnamespace Localizer.DataModel.Default\n{\n    public class BuffEntry : IEntry\n    {\n        [ModTranslationProp(\"DisplayName\")] public BaseEntry Name { get; set; }\n\n        [ModTranslationProp(\"Description\")] public BaseEntry Description { get; set; }\n\n        public IEntry Clone()\n        {\n            return new BuffEntry\n            {\n                Name = Name.Clone() as BaseEntry,\n                Description = Description.Clone() as BaseEntry\n            };\n        }\n    }\n\n    public class BasicBuffFile : IFile\n    {\n        [ModTranslationOwnerField(\"buffs\")]\n        public Dictionary<string, BuffEntry> Buffs { get; set; } = new Dictionary<string, BuffEntry>();\n\n        public List<string> GetKeys()\n        {\n            return Buffs.Keys.ToList();\n        }\n\n        public IEntry GetValue(string key)\n        {\n            return Buffs[key];\n        }\n    }\n}\n"
  },
  {
    "path": "Localizer/DataModel/Default/BasicItemFile.cs",
    "content": "﻿using System.Collections.Generic;\nusing System.Linq;\nusing Localizer.Attributes;\n\nnamespace Localizer.DataModel.Default\n{\n    public class ItemEntry : IEntry\n    {\n        [ModTranslationProp(\"DisplayName\")] public BaseEntry Name { get; set; }\n\n        [ModTranslationProp(\"Tooltip\")] public BaseEntry Tooltip { get; set; }\n\n        public IEntry Clone()\n        {\n            return new ItemEntry\n            {\n                Name = Name.Clone() as BaseEntry,\n                Tooltip = Tooltip.Clone() as BaseEntry\n            };\n        }\n    }\n\n    public class BasicItemFile : IFile\n    {\n        [ModTranslationOwnerField(\"items\")]\n        public Dictionary<string, ItemEntry> Items { get; set; } = new Dictionary<string, ItemEntry>();\n\n        public List<string> GetKeys()\n        {\n            return Items.Keys.ToList();\n        }\n\n        public IEntry GetValue(string key)\n        {\n            return Items[key];\n        }\n    }\n}\n"
  },
  {
    "path": "Localizer/DataModel/Default/BasicNPCFile.cs",
    "content": "﻿using System.Collections.Generic;\nusing System.Linq;\nusing Localizer.Attributes;\n\nnamespace Localizer.DataModel.Default\n{\n    public class NPCEntry : IEntry\n    {\n        [ModTranslationProp(\"DisplayName\")] public BaseEntry Name { get; set; }\n\n        public IEntry Clone()\n        {\n            return new NPCEntry { Name = Name.Clone() as BaseEntry };\n        }\n    }\n\n    public class BasicNPCFile : IFile\n    {\n        [ModTranslationOwnerField(\"npcs\")]\n        public Dictionary<string, NPCEntry> NPCs { get; set; } = new Dictionary<string, NPCEntry>();\n\n        public List<string> GetKeys()\n        {\n            return NPCs.Keys.ToList();\n        }\n\n        public IEntry GetValue(string key)\n        {\n            return NPCs[key];\n        }\n    }\n}\n"
  },
  {
    "path": "Localizer/DataModel/Default/BasicPrefixFile.cs",
    "content": "using System.Collections.Generic;\nusing System.Linq;\nusing Localizer.Attributes;\n\nnamespace Localizer.DataModel.Default\n{\n    public class PrefixEntry : IEntry\n    {\n        [ModTranslationProp(\"DisplayName\")] public BaseEntry Name { get; set; }\n\n        public IEntry Clone()\n        {\n            return new PrefixEntry { Name = Name.Clone() as BaseEntry };\n        }\n    }\n\n    public class BasicPrefixFile : IFile\n    {\n        [ModTranslationOwnerField(\"prefixes\")]\n        public Dictionary<string, PrefixEntry> Prefixes { get; set; } = new Dictionary<string, PrefixEntry>();\n\n        public List<string> GetKeys()\n        {\n            return Prefixes.Keys.ToList();\n        }\n\n        public IEntry GetValue(string key)\n        {\n            return Prefixes[key];\n        }\n    }\n}\n"
  },
  {
    "path": "Localizer/DataModel/Default/BasicProjectileFile.cs",
    "content": "using System.Collections.Generic;\nusing System.Linq;\nusing Localizer.Attributes;\n\nnamespace Localizer.DataModel.Default\n{\n    public class ProjectileEntry : IEntry\n    {\n        [ModTranslationProp(\"DisplayName\")] public BaseEntry Name { get; set; }\n\n        public IEntry Clone()\n        {\n            return new ProjectileEntry { Name = Name.Clone() as BaseEntry };\n        }\n    }\n\n    public class BasicProjectileFile : IFile\n    {\n        [ModTranslationOwnerField(\"projectiles\")]\n        public Dictionary<string, ProjectileEntry> Projectiles { get; set; } = new Dictionary<string, ProjectileEntry>();\n\n        public List<string> GetKeys()\n        {\n            return Projectiles.Keys.ToList();\n        }\n\n        public IEntry GetValue(string key)\n        {\n            return Projectiles[key];\n        }\n    }\n}\n"
  },
  {
    "path": "Localizer/DataModel/Default/CustomModTranslationFile.cs",
    "content": "using System.Collections.Generic;\nusing System.Linq;\n\nnamespace Localizer.DataModel.Default\n{\n    public class CustomModTranslationFile : IFile\n    {\n        public Dictionary<string, BaseEntry> Translations { get; set; } = new Dictionary<string, BaseEntry>();\n\n        public List<string> GetKeys()\n        {\n            return Translations.Keys.ToList();\n        }\n\n        public IEntry GetValue(string key)\n        {\n            return Translations[key];\n        }\n    }\n}\n"
  },
  {
    "path": "Localizer/DataModel/Default/ExportConfig.cs",
    "content": "namespace Localizer.DataModel.Default\n{\n    public class ExportConfig : IExportConfig\n    {\n        public bool MakeBackup { get; set; }\n        public bool ForceOverride { get; set; }\n        public bool WithTranslation { get; set; }\n    }\n}\n"
  },
  {
    "path": "Localizer/DataModel/Default/File.cs",
    "content": "﻿using System.Collections.Generic;\nusing Newtonsoft.Json;\n\nnamespace Localizer.DataModel.Default\n{\n    public abstract class File : IFile\n    {\n        [JsonIgnore] public IPackage Owner { get; set; }\n\n        public abstract List<string> GetKeys();\n\n        public abstract IEntry GetValue(string key);\n\n        public abstract void AddEntry(string key, IEntry entry);\n    }\n}\n"
  },
  {
    "path": "Localizer/DataModel/Default/GitHubUpdateInfo.cs",
    "content": "using System;\n\nnamespace Localizer.DataModel.Default\n{\n    public class GitHubUpdateInfo : IUpdateInfo\n    {\n        public UpdateType Type { get; }\n\n        public Version Version { get; }\n\n        private string versionString;\n\n        public GitHubUpdateInfo(string versionString)\n        {\n            this.versionString = versionString;\n            Type = ParseType(versionString[0]);\n            Version = Version.Parse(versionString.Substring(1, versionString.Length - 1));\n        }\n\n        internal UpdateType ParseType(char t)\n        {\n            switch (t)\n            {\n                case 'a':\n                    return UpdateType.Minor;\n                case 'b':\n                    return UpdateType.Major;\n                case 'c':\n                    return UpdateType.Critical;\n                default:\n                    return UpdateType.None;\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "Localizer/DataModel/Default/LdstrFile.cs",
    "content": "using System.Collections.Generic;\nusing System.Linq;\nusing Localizer.Attributes;\n\nnamespace Localizer.DataModel.Default\n{\n    public class LdstrEntry : IEntry\n    {\n        public List<BaseEntry> Instructions { get; set; }\n\n        public IEntry Clone()\n        {\n            var entry = new LdstrEntry { Instructions = new List<BaseEntry>() };\n\n            foreach (var ins in Instructions)\n            {\n                entry.Instructions.Add(ins.Clone() as BaseEntry);\n            }\n\n            return entry;\n        }\n    }\n\n    [OperationTiming]\n    public class LdstrFile : IFile\n    {\n        public Dictionary<string, LdstrEntry> LdstrEntries { get; set; } = new Dictionary<string, LdstrEntry>();\n\n        public List<string> GetKeys()\n        {\n            return LdstrEntries.Keys.ToList();\n        }\n\n        public IEntry GetValue(string key)\n        {\n            return LdstrEntries[key];\n        }\n    }\n}\n"
  },
  {
    "path": "Localizer/DataModel/Default/LoadedModWrapper.cs",
    "content": "using System;\nusing System.Reflection;\nusing Terraria;\nusing Terraria.ModLoader;\nusing Terraria.ModLoader.Core;\n\nnamespace Localizer.DataModel.Default\n{\n    public class LoadedModWrapper : IMod\n    {\n        internal readonly WeakReference<object> wrapped;\n\n        public LoadedModWrapper(object mod)\n        {\n            wrapped = new WeakReference<object>(mod);\n            name = mod.ValueOf<string>(\"Name\");\n            Code = name == \"ModLoader\" ? Assembly.GetAssembly(typeof(Main)) : mod.ValueOf<Assembly>(\"assembly\");\n            var buildProp = mod.ValueOf(\"properties\");\n            displayName = buildProp.ValueOf<string>(\"displayName\");\n            version = buildProp.ValueOf<Version>(\"version\");\n            File = mod.ValueOf<TmodFile>(\"modFile\");\n        }\n\n        public string Name => name ?? \"\";\n        private string name;\n\n        public Assembly Code { get; }\n\n        public string DisplayName => displayName ?? \"\";\n        private string displayName;\n\n        public Version Version => version ?? new Version();\n        private Version version;\n\n        public TmodFile File { get; }\n\n        public bool Enabled => (bool)typeof(ModLoader).Invoke(\"IsEnabled\", Name);\n    }\n}\n"
  },
  {
    "path": "Localizer/DataModel/Default/ModWrapper.cs",
    "content": "using System;\nusing System.Reflection;\nusing Terraria;\nusing Terraria.ModLoader;\nusing Terraria.ModLoader.Core;\n\nnamespace Localizer.DataModel.Default\n{\n    public class ModWrapper : IMod\n    {\n        private readonly WeakReference<Mod> wrapped;\n\n        public ModWrapper(Mod mod)\n        {\n            if (mod is null)\n            {\n                throw new ArgumentNullException(nameof(mod));\n            }\n\n            wrapped = new WeakReference<Mod>(mod);\n        }\n\n        public Mod Mod\n        {\n            get\n            {\n                Mod mod = null;\n                wrapped?.TryGetTarget(out mod);\n                return mod;\n            }\n        }\n\n        public string Name => Mod?.Name ?? \"\";\n\n        public Assembly Code\n        {\n            get\n            {\n\n                if (Name == \"ModLoader\")\n                {\n                    return Assembly.GetAssembly(typeof(Main));\n                }\n                else\n                {\n                    return Mod?.Code;\n                }\n            }\n        }\n\n        public string DisplayName => Mod.DisplayName ?? \"\";\n        public Version Version => Mod?.Version;\n        public TmodFile File => Mod?.ValueOf<TmodFile>(\"File\");\n        public bool Enabled => (bool)typeof(ModLoader).Invoke(\"IsEnabled\", Name);\n    }\n}\n"
  },
  {
    "path": "Localizer/DataModel/Default/Package.cs",
    "content": "using System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.Linq;\nusing Newtonsoft.Json;\n\nnamespace Localizer.DataModel.Default\n{\n    [JsonObject(MemberSerialization.OptIn)]\n    public class Package : IPackage\n    {\n        public Package()\n        { }\n\n        public Package(string name, IMod mod, CultureInfo language)\n        {\n            Name = name;\n            Mod = mod;\n            ModName = mod.Name;\n            Description = string.Empty;\n            Language = language;\n            Version = new Version(1, 0, 0, 0);\n\n            FileList = new List<string>();\n            Files = new List<IFile>();\n        }\n\n        public bool Exported { get; set; }\n        [JsonProperty] public string Name { get; set; } = \"\";\n        [JsonProperty] public string Author { get; set; } = \"\";\n        [JsonProperty] public string ModName { get; set; } = \"\";\n        [JsonProperty] public string Description { get; set; } = \"\";\n        [JsonProperty] public string LocalizedModName { get; set; } = \"\";\n        [JsonProperty] public Version Version { get; set; }\n        [JsonProperty] public Version ModVersion { get; set; }\n        [JsonProperty] public CultureInfo Language { get; set; } = CultureInfo.GetCultureInfo(\"en-US\");\n        [JsonProperty] public ICollection<string> FileList { get; set; } = new List<string>();\n\n        public ICollection<IFile> Files { get; set; } = new List<IFile>();\n        public int Count => Files.Sum(f => f.GetKeys().Count());\n\n        public bool Enabled { get; set; } = true;\n\n        public IMod Mod { get; set; }\n\n        public void AddFile(IFile file)\n        {\n            if (file == null)\n            {\n                return;\n            }\n\n            if (!FileList.Contains(file.GetType().Name))\n            {\n                FileList.Add(file.GetType().Name);\n            }\n\n            Files.Add(file);\n        }\n\n        public void RemoveFile(IFile file)\n        {\n            throw new NotImplementedException();\n        }\n    }\n}\n"
  },
  {
    "path": "Localizer/DataModel/Default/PackageGroup.cs",
    "content": "using System.Collections.Generic;\n\nnamespace Localizer.DataModel.Default\n{\n    public class PackageGroup : IPackageGroup\n    {\n        public IMod Mod { get; set; }\n\n        public ICollection<IPackage> Packages { get; set; }\n    }\n}\n"
  },
  {
    "path": "Localizer/DataModel/Default/PackageGroupState.cs",
    "content": "using System.Collections.Specialized;\nusing Newtonsoft.Json;\n\nnamespace Localizer.DataModel.Default\n{\n    [JsonObject(MemberSerialization.OptOut)]\n    public class PackageGroupState\n    {\n        public PackageGroupState()\n        { }\n\n        public PackageGroupState(IPackageGroup pg)\n        {\n            ModName = pg.Mod.Name;\n            Packages = new OrderedDictionary();\n            foreach (var p in pg.Packages)\n            {\n                Packages.Add(p.Name, p.Enabled);\n            }\n        }\n\n        public string ModName { get; set; }\n\n        public OrderedDictionary Packages { get; set; }\n    }\n}\n"
  },
  {
    "path": "Localizer/DataModel/IEntry.cs",
    "content": "namespace Localizer.DataModel\n{\n    public interface IEntry\n    {\n        IEntry Clone();\n    }\n}\n"
  },
  {
    "path": "Localizer/DataModel/IExportConfig.cs",
    "content": "namespace Localizer.DataModel\n{\n    public interface IExportConfig\n    {\n        /// <summary>\n        ///     Create backups before exportation.\n        /// </summary>\n        bool MakeBackup { get; set; }\n\n        /// <summary>\n        ///     Overwrite or not if the file is already exists.\n        /// </summary>\n        bool ForceOverride { get; set; }\n\n        /// <summary>\n        ///     If the ModTranslation already has a translation of current culture,\n        ///     then export it.\n        /// </summary>\n        bool WithTranslation { get; set; }\n    }\n}\n"
  },
  {
    "path": "Localizer/DataModel/IFile.cs",
    "content": "using System.Collections.Generic;\n\nnamespace Localizer.DataModel\n{\n    public interface IFile\n    {\n        List<string> GetKeys();\n        IEntry GetValue(string key);\n    }\n}\n"
  },
  {
    "path": "Localizer/DataModel/IMod.cs",
    "content": "using System;\nusing System.Reflection;\nusing Terraria.ModLoader.Core;\n\nnamespace Localizer.DataModel\n{\n    public interface IMod\n    {\n        /// <summary>\n        ///     Name of the mod.\n        /// </summary>\n        string Name { get; }\n\n        /// <summary>\n        ///     Code of the mod.\n        /// </summary>\n        Assembly Code { get; }\n\n        /// <summary>\n        ///     DisplayName of the mod.\n        /// </summary>\n        string DisplayName { get; }\n\n        /// <summary>\n        ///     Version of the mod.\n        /// </summary>\n        Version Version { get; }\n\n        /// <summary>\n        /// File of the mod.\n        /// </summary>\n        TmodFile File { get; }\n\n        bool Enabled { get; }\n    }\n}\n"
  },
  {
    "path": "Localizer/DataModel/IPackage.cs",
    "content": "using System;\nusing System.Collections.Generic;\nusing System.Globalization;\n\nnamespace Localizer.DataModel\n{\n    public interface IPackage\n    {\n        /// <summary>\n        ///     Name of the package.\n        /// </summary>\n        string Name { get; set; }\n\n        /// <summary>\n        ///     Author of the package.\n        /// </summary>\n        string Author { get; set; }\n\n        /// <summary>\n        ///     The name of the mod this package target for.\n        /// </summary>\n        string ModName { get; set; }\n\n        /// <summary>\n        ///     The localized name of the mod.\n        /// </summary>\n        string LocalizedModName { get; set; }\n\n        /// <summary>\n        ///     Description of the package.\n        /// </summary>\n        string Description { get; set; }\n\n        /// <summary>\n        ///     Version of the package.\n        /// </summary>\n        Version Version { get; set; }\n\n        /// <summary>\n        ///     Version of the targeted mod.\n        /// </summary>\n        Version ModVersion { get; set; }\n\n        /// <summary>\n        ///     Culture of the package.\n        /// </summary>\n        CultureInfo Language { get; set; }\n\n        /// <summary>\n        ///     File types this package including.\n        /// </summary>\n        ICollection<string> FileList { get; set; }\n\n        /// <summary>\n        ///     Files this package including.\n        /// </summary>\n        ICollection<IFile> Files { get; set; }\n\n        int Count { get; }\n\n        /// <summary>\n        ///     The enable status of the package.\n        /// </summary>\n        bool Enabled { get; set; }\n\n        /// <summary>\n        ///     The mod this package target for.\n        /// </summary>\n        IMod Mod { get; set; }\n\n        /// <summary>\n        ///     Add a file into Files and FileList\n        /// </summary>\n        /// <param name=\"file\"></param>\n        void AddFile(IFile file);\n\n        /// <summary>\n        ///     Remove a file from Files and FileList\n        /// </summary>\n        /// <param name=\"file\"></param>\n        void RemoveFile(IFile file);\n    }\n}\n"
  },
  {
    "path": "Localizer/DataModel/IPackageGroup.cs",
    "content": "using System.Collections.Generic;\n\nnamespace Localizer.DataModel\n{\n    public interface IPackageGroup\n    {\n        /// <summary>\n        ///     Mod of the group, every package in this group is for this mod.\n        /// </summary>\n        IMod Mod { get; set; }\n\n        ICollection<IPackage> Packages { get; set; }\n    }\n}\n"
  },
  {
    "path": "Localizer/DataModel/IUpdateInfo.cs",
    "content": "using System;\n\nnamespace Localizer.DataModel\n{\n    public enum UpdateType\n    {\n        None,\n        Minor,\n        Major,\n        Critical,\n    }\n\n    public interface IUpdateInfo\n    {\n        UpdateType Type { get; }\n\n        Version Version { get; }\n    }\n}\n"
  },
  {
    "path": "Localizer/Disposable.cs",
    "content": "using System;\n\nnamespace Localizer\n{\n    public abstract class Disposable : IDisposable\n    {\n        protected bool disposed = false;\n\n        public void Dispose()\n        {\n            Dispose(true);\n            GC.SuppressFinalize(this);\n        }\n\n        ~Disposable()\n        {\n            Dispose(false);\n        }\n\n        protected virtual void Dispose(bool disposeManaged)\n        {\n            if (!disposed)\n            {\n                if (disposeManaged)\n                {\n                    DisposeManaged();\n                }\n\n                DisposeUnmanaged();\n\n                disposed = true;\n            }\n        }\n\n        protected virtual void DisposeManaged() { }\n\n        protected virtual void DisposeUnmanaged() { }\n    }\n}\n"
  },
  {
    "path": "Localizer/Enums/AutoImportType.cs",
    "content": "using Newtonsoft.Json;\nusing Newtonsoft.Json.Converters;\n\nnamespace Localizer\n{\n    [JsonConverter(typeof(StringEnumConverter))]\n    public enum AutoImportType\n    {\n        All,\n        DownloadedOnly,\n        SourceOnly,\n    }\n}\n"
  },
  {
    "path": "Localizer/Enums/LogLevel.cs",
    "content": "using Newtonsoft.Json;\nusing Newtonsoft.Json.Converters;\n\nnamespace Localizer\n{\n    [JsonConverter(typeof(StringEnumConverter))]\n    public enum LogLevel : byte\n    {\n        Fatal = 0,\n        Error = 1,\n        Warn = 2,\n        Info = 3,\n        Debug = 4,\n    }\n}\n"
  },
  {
    "path": "Localizer/Enums/OperationTiming.cs",
    "content": "using System;\n\nnamespace Localizer\n{\n    [Flags]\n    public enum OperationTiming : byte\n    {\n        BeforeModCtor = 0b00000001,\n        BeforeModLoad = 0b00000010,\n        BeforeContentLoad = 0b00000100,\n        PostContentLoad = 0b00001000,\n        Any = 0b11111111,\n    }\n}\n"
  },
  {
    "path": "Localizer/Enums/PackageType.cs",
    "content": "namespace Localizer\n{\n    public enum PackageType\n    {\n        Packed,\n        Source,\n    }\n}\n"
  },
  {
    "path": "Localizer/Helpers/Extensions.cs",
    "content": "using System;\nusing System.Globalization;\nusing System.Linq;\nusing System.Reflection;\nusing Localizer.Attributes;\nusing Localizer.DataModel.Default;\nusing Terraria.ModLoader;\n\nnamespace Localizer.Helpers\n{\n    public static class Extensions\n    {\n        #region ModTranslation\n\n        public static void Import(this ModTranslation modTranslation, BaseEntry entry, CultureInfo culture)\n        {\n            if (entry != null)\n            {\n                if (entry.Origin != modTranslation.GetDefault()\n                    && modTranslation.GetDefault() != modTranslation.Key\n                    && !string.IsNullOrWhiteSpace(modTranslation.GetDefault())\n                    && !string.IsNullOrWhiteSpace(entry.Origin))\n                {\n                    Utils.LogWarn(\n                        $\"Mismatch origin text when importing \\\"{modTranslation.Key}\\\"{Environment.NewLine}Origin in mod: {modTranslation.GetDefault()}{Environment.NewLine}Origin in package: {entry.Origin}{Environment.NewLine}Translation in package: {entry.Translation}\");\n                    return;\n                }\n\n                if (modTranslation.GetDefault() != null && !string.IsNullOrEmpty(entry.Translation) &&\n                    entry.Translation != modTranslation.Key)\n                {\n                    modTranslation.AddTranslation(Localizer.CultureInfoToGameCulture(culture), entry.Translation);\n                }\n            }\n        }\n\n        public static string GetTranslation(this ModTranslation modTranslation, CultureInfo culture)\n        {\n            var translation = modTranslation.GetTranslation(Localizer.CultureInfoToGameCulture(culture));\n            return string.IsNullOrWhiteSpace(translation) ? \"\" : translation;\n        }\n\n        public static string DefaultOrEmpty(this ModTranslation modTranslation)\n        {\n            var d = modTranslation.GetDefault();\n            return string.IsNullOrWhiteSpace(d) || d == modTranslation.Key ? \"\" : d;\n        }\n\n        #endregion\n\n        #region Reflection\n        public static PropertyInfo[] ModTranslationOwnerField(this Type type)\n        {\n            return type.GetProperties().Where(p => p.GetCustomAttribute<ModTranslationOwnerFieldAttribute>() != null)\n                       .ToArray();\n        }\n\n        public static string ModTranslationOwnerFieldName(this PropertyInfo prop)\n        {\n            return prop.GetCustomAttribute<ModTranslationOwnerFieldAttribute>()?.FieldName;\n        }\n\n        public static PropertyInfo[] ModTranslationProp(this Type type)\n        {\n            return type.GetProperties().Where(p => p.GetCustomAttribute<ModTranslationPropAttribute>() != null)\n                       .ToArray();\n        }\n\n        #endregion\n    }\n}\n"
  },
  {
    "path": "Localizer/Helpers/Reflection.cs",
    "content": "using System.Collections.Generic;\nusing System.Linq;\nusing System.Linq.Expressions;\nusing Harmony;\n\nnamespace System.Reflection\n{\n    public static class NoroHelper\n    {\n        public const BindingFlags AnyVisibility = BindingFlags.Public | BindingFlags.NonPublic;\n        public const BindingFlags Any = AnyVisibility | BindingFlags.Static | BindingFlags.Instance;\n\n        public static HarmonyMethod HarmonyMethod(Expression<Action> expression)\n        {\n            return new HarmonyMethod((expression.Body as MethodCallExpression)?.Method);\n        }\n\n        public static MethodInfo MethodInfo(Expression<Action> expression)\n        {\n            return (expression.Body as MethodCallExpression)?.Method;\n        }\n\n        public static Type Type(this string name)\n        {\n            //return AppDomain.CurrentDomain.GetAssemblies().SelectMany(a => a.DefinedTypes).FirstOrDefault(t => t.FullName == name);\n            return AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(a => a.DefinedTypes.Any(t => t.FullName == name))?.ManifestModule.GetType(name);\n        }\n\n        public static FieldInfo Field(this Type type, string name, BindingFlags flags = Any)\n        {\n            return type?.GetField(name, flags) ?? type?.BaseType?.Field(name, flags);\n        }\n\n        public static PropertyInfo Property(this Type type, string name, BindingFlags flags = Any)\n        {\n            return type?.GetProperty(name, flags) ?? type?.BaseType?.Property(name, flags);\n        }\n\n        public static MethodInfo Method(this Type t, string name, IEnumerable<Type> args)\n        {\n            return t.Method(name, args.ToArray());\n        }\n\n        public static MethodInfo Method(this Type t, string name, params Type[] args)\n        {\n            if (name is null)\n            {\n                throw new ArgumentNullException(nameof(name));\n            }\n\n            if (args == null || args.Length == 0)\n            {\n                return t.GetMethod(name, Any);\n            }\n\n            return t.GetMethod(name, Any, null, args, new ParameterModifier[] { });\n        }\n\n        public static object ValueOf(this Type type, string name, object value = null)\n        {\n            var field = type?.Field(name);\n            if (field != null)\n            {\n                return field.GetValue(value);\n            }\n\n            var prop = type?.Property(name);\n            if (prop != null)\n            {\n                return prop.GetValue(value);\n            }\n\n            throw new MemberAccessException($\"{name} not found ({type})\");\n        }\n\n        public static object ValueOf(this object obj, string name)\n        {\n            return obj?.GetType().ValueOf(name, obj);\n        }\n\n        public static T ValueOf<T>(this Type type, string name)\n        {\n            return (T)type?.ValueOf(name);\n        }\n\n        public static T ValueOf<T>(this object obj, string name)\n        {\n            return (T)obj?.ValueOf(name);\n        }\n\n        public static void SetField(this Type type, string name, object value)\n        {\n            type?.Field(name).SetValue(null, value);\n        }\n\n        public static void SetField(this object obj, string name, object value)\n        {\n            obj?.GetType().Field(name).SetValue(obj, value);\n        }\n\n        public static object Invoke(this object o, string name, params object[] args)\n        {\n            if (name is null)\n            {\n                throw new ArgumentNullException(nameof(name));\n            }\n\n            var method = (o is Type t\n                ? t\n                : o.GetType()).Method(name, args.Select(a => a.GetType()))\n                     ?? throw new MissingMethodException($\"{o.GetType().FullName}.{name}\");\n            return method.Invoke(o, args);\n        }\n    }\n}\n"
  },
  {
    "path": "Localizer/Helpers/UI.cs",
    "content": "using System;\nusing System.Reflection;\nusing Localizer.DataModel;\nusing Microsoft.Xna.Framework.Graphics;\nusing Terraria.UI;\nusing static Localizer.Lang;\n\nnamespace Localizer.Helpers\n{\n    public static class UI\n    {\n        public static string GetPkgLabelText(IPackage p)\n        {\n            return _(\"PackageDisplay\", _(p.Enabled ? \"PackageEnabled\" : \"PackageDisabled\"), p.Name, p.Version, p.Author);\n        }\n\n        public static void ShowInfoMessage(string message, int gotoMenu, UIState state = null, string altButtonText = \"\", Action altButtonAction = null)\n        {\n            var infoMsgUI = GetModLoaderUI(\"infoMessage\") ?? throw new Exception(\"Cannot Find infoMessage field\");\n\n            infoMsgUI.Invoke(\"Show\", message, gotoMenu, state, altButtonText, altButtonAction);\n        }\n\n        public static object GetModLoaderUI(string uiName)\n        {\n            return \"Terraria.ModLoader.UI.Interface\".Type()?.ValueOf(uiName);\n        }\n\n        public static void SafeBegin(this SpriteBatch sb)\n        {\n            try\n            {\n                sb.Begin();\n            }\n            catch (InvalidOperationException)\n            {\n            }\n        }\n        public static void SafeBegin(this SpriteBatch sb, SamplerState sampler, RasterizerState rasterizer)\n        {\n            try\n            {\n                sb.Begin(SpriteSortMode.Immediate, BlendState.NonPremultiplied, sampler, null, rasterizer);\n            }\n            catch (InvalidOperationException)\n            {\n            }\n        }\n\n        public static void SafeEnd(this SpriteBatch sb)\n        {\n            try\n            {\n                sb.End();\n            }\n            catch (InvalidOperationException)\n            {\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "Localizer/Helpers/Utils.cs",
    "content": "using System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.IO.Compression;\nusing System.Linq;\nusing System.Net;\nusing System.Reflection;\nusing System.Reflection.Emit;\nusing System.Text;\nusing System.Text.RegularExpressions;\nusing Harmony;\nusing Harmony.ILCopying;\nusing Localizer.Attributes;\nusing Localizer.DataModel;\nusing Localizer.DataModel.Default;\nusing Localizer.Helpers;\nusing Mono.Cecil;\nusing MonoMod.Utils;\nusing Newtonsoft.Json;\nusing Newtonsoft.Json.Converters;\nusing Terraria.ModLoader;\nusing File = System.IO.File;\n\n// ReSharper disable once CheckNamespace\nnamespace Localizer\n{\n    public static partial class Utils\n    {\n        #region Zip\n\n        /// <summary>\n        ///     Add a file into a ZipArchive as an entry.\n        /// </summary>\n        /// <param name=\"archive\">Target archive.</param>\n        /// <param name=\"filePath\">The path of the file.</param>\n        /// <param name=\"entryName\">Entry name in the archive.</param>\n        public static void WriteZipArchiveEntry(ZipArchive archive, string filePath, string entryName)\n        {\n            var fileEntry = archive.CreateEntry(entryName);\n            using (var stream = fileEntry.Open())\n            {\n                var fileBytes = File.ReadAllBytes(filePath);\n                stream.Write(fileBytes, 0, fileBytes.Length);\n            }\n        }\n\n        #endregion\n\n        #region Reflection\n\n        /// <summary>\n        ///     Return the method matched with the findableName in the given type.\n        ///     Return null if fail.\n        /// </summary>\n        /// <param name=\"findableName\"></param>\n        /// <typeparam name=\"T\"></typeparam>\n        /// <returns></returns>\n        public static MethodBase GetMethodBase<T>(string findableName)\n        {\n            var method = typeof(T).FindMethod(findableName);\n            return method != null ? MethodBase.GetMethodFromHandle(method.MethodHandle) : null;\n        }\n\n        private static Dictionary<Module, Dictionary<string, MethodBase>> _cachedMethod = new Dictionary<Module, Dictionary<string, MethodBase>>();\n        public static MethodBase FindMethodByID(Module m, string findableName)\n        {\n            if (!_cachedMethod.ContainsKey(m))\n            {\n                _cachedMethod.Add(m, new Dictionary<string, MethodBase>());\n                foreach (var t in m.GetTypes())\n                {\n                    foreach (var method in t.GetMethods(NoroHelper.Any))\n                    {\n                        var key = method.GetID();\n                        if (!_cachedMethod[m].ContainsKey(key))\n                        {\n                            _cachedMethod[m].Add(key, method);\n                        }\n                    }\n                }\n            }\n\n            return _cachedMethod[m].ContainsKey(findableName) ? _cachedMethod[m][findableName] : null;\n        }\n\n        private static Regex genericTypeMatch = new Regex(@\"\\[\\[(.*?), .*?\\]\\]\", RegexOptions.Compiled);\n        public static MethodDefinition FindMethodByID(ModuleDefinition m, string findableName)\n        {\n            var cecilName = genericTypeMatch.Replace(findableName, \"<$1>\");\n            foreach (var t in m.GetTypes())\n            {\n                foreach (var method in t.Methods)\n                {\n                    var id = method.GetID();\n                    if (id == findableName)\n                    {\n                        return method;\n                    }\n\n                    if (id == cecilName)\n                    {\n                        return method;\n                    }\n                }\n            }\n\n            return null;\n        }\n\n        #endregion\n\n        #region Json\n\n        /// <summary>\n        ///     Serialize an object and write to disk.\n        /// </summary>\n        /// <param name=\"obj\">Object want to serialize.</param>\n        /// <param name=\"path\">Store path of the serialized file.</param>\n        /// <param name=\"indent\"></param>\n        public static void SerializeJsonAndCreateFile(object obj, string path, bool indent = true)\n        {\n            using (var fs = new FileStream(path, FileMode.Create, FileAccess.Write))\n            {\n                using (var sw = new StreamWriter(fs))\n                {\n                    sw.Write(JsonConvert.SerializeObject(obj, indent ? Formatting.Indented : Formatting.None, new VersionConverter()));\n                }\n            }\n        }\n\n        /// <summary>\n        ///     Read a file return the deserialized object.\n        /// </summary>\n        /// <param name=\"path\">Path of the file.</param>\n        /// <typeparam name=\"T\">The type of result.</typeparam>\n        /// <returns></returns>\n        public static T ReadFileAndDeserializeJson<T>(string path)\n        {\n            using (var fs = new FileStream(path, FileMode.Open, FileAccess.Read))\n            {\n                return ReadFileAndDeserializeJson<T>(fs);\n            }\n        }\n\n        /// <summary>\n        ///     Read a stream return the deserialized object.\n        /// </summary>\n        /// <param name=\"stream\">Stream want to deserialize.</param>\n        /// <typeparam name=\"T\">The type of result.</typeparam>\n        /// <returns></returns>\n        public static T ReadFileAndDeserializeJson<T>(Stream stream)\n        {\n            using (var sr = new StreamReader(stream))\n            {\n                var content = sr.ReadToEnd();\n                try\n                {\n                    return JsonConvert.DeserializeObject<T>(content, new VersionConverter());\n                }\n                catch\n                {\n                    return JsonConvert.DeserializeObject<T>(content);\n                }\n            }\n        }\n\n        /// <summary>\n        ///     Read a file return the deserialized object.\n        /// </summary>\n        /// <param name=\"t\">The type of result.</param>\n        /// <param name=\"path\">Path of the file.</param>\n        /// <returns></returns>\n        public static object ReadFileAndDeserializeJson(Type t, string path)\n        {\n            using (var fs = new FileStream(path, FileMode.Open, FileAccess.Read))\n            {\n                return ReadFileAndDeserializeJson(t, fs);\n            }\n        }\n\n        /// <summary>\n        ///     Read a file return the deserialized object.\n        /// </summary>\n        /// <param name=\"t\">The type of result.</param>\n        /// <param name=\"stream\">Stream want to deserialize.</param>\n        /// <returns></returns>\n        public static object ReadFileAndDeserializeJson(Type t, Stream stream)\n        {\n            using (var sr = new StreamReader(stream))\n            {\n                return JsonConvert.DeserializeObject(sr.ReadToEnd(), t);\n            }\n        }\n\n        #endregion\n\n        #region GameCulture\n\n        #endregion\n\n        #region Log\n\n        public static void LogFatal(object o)\n        {\n            Localizer.Log.Fatal(o);\n        }\n\n        public static void LogError(object o)\n        {\n            if (Localizer.Config.LogLevel >= LogLevel.Error)\n            {\n                Localizer.Log.Error(o);\n            }\n        }\n\n        public static void LogWarn(object o)\n        {\n            if (Localizer.Config.LogLevel >= LogLevel.Warn)\n            {\n                Localizer.Log.Warn(o);\n            }\n        }\n\n        public static void LogInfo(object o)\n        {\n            if (Localizer.Config.LogLevel >= LogLevel.Info)\n            {\n                Localizer.Log.Info(o);\n            }\n        }\n\n        public static void LogDebug(object o)\n        {\n            if (Localizer.Config.LogLevel >= LogLevel.Debug)\n            {\n                Localizer.Log.Debug(o);\n            }\n        }\n        #endregion\n\n        #region Network\n\n        internal static string UserAgent(bool localizer = true)\n        {\n            if (!localizer)\n            {\n                // Request by tModLoader\n                return $\"tModLoader/{ModLoader.versionTag} ({Environment.OSVersion}; {(Environment.Is64BitOperatingSystem ? \"x64\" : \"x86\")})\";\n            }\n            return $\"Localizer/{Localizer.Instance.Version} ({Environment.OSVersion}; {(Environment.Is64BitOperatingSystem ? \"x64\" : \"x86\")}) tModLoader/{ModLoader.versionTag} ({(Environment.Is64BitOperatingSystem ? \"x64\" : \"x86\")})\";\n        }\n\n        public static HttpWebResponse GET(string url)\n        {\n            var request = (HttpWebRequest)WebRequest.Create(url);\n            request.Method = \"GET\";\n            request.ContentType = \"application/json;charset=UTF-8\";\n            request.Accept = \"application/vnd.github.v3+json\";\n            request.UserAgent = UserAgent();\n            request.Timeout = 9000;\n            request.Headers[\"Accept-Language\"] = Terraria.Localization.LanguageManager.Instance.ActiveCulture.CultureInfo.ToString();\n\n            return (HttpWebResponse)request.GetResponse();\n        }\n\n        public static string GetResponseBody(HttpWebResponse response)\n        {\n            if (response == null)\n            {\n                return null;\n            }\n\n            var encoding = Encoding.UTF8;\n\n            using (var myResponseStream = response.GetResponseStream())\n            {\n                using (var myStreamReader = new StreamReader(myResponseStream, encoding))\n                {\n                    return myStreamReader.ReadToEnd();\n                }\n            }\n        }\n\n        #endregion\n\n        #region Others\n\n        public static string AsRainbow(string text, int frameCounter, int? unit = null)\n        {\n            var rainbowText = \"\";\n            var hueUnit = 4f / (unit ?? text.Length);\n            var baseHue = (frameCounter % 300) / 300f;\n            for (var i = 0; i < text.Length; i++)\n            {\n                var colorHue = baseHue + hueUnit * i / text.Length;\n                var color = Terraria.Main.hslToRgb(1.5f - colorHue, 1, 0.7f);\n                rainbowText += $\"[c/{color.R:X2}{color.G:X2}{color.B:X2}:{text[i]}]\";\n            }\n            return rainbowText;\n        }\n\n        /// <summary>\n        ///     Create mappings from the name of actual ModTranslation container in the mod to the property\n        ///     in the translation file.\n        /// </summary>\n        /// <param name=\"entryType\"></param>\n        /// <returns></returns>\n        public static Dictionary<string, PropertyInfo> CreateEntryMappings(Type entryType)\n        {\n            if (entryType == null)\n            {\n                throw new ArgumentNullException();\n            }\n\n            var mappings = new Dictionary<string, PropertyInfo>();\n\n            foreach (var prop in entryType.ModTranslationProp())\n            {\n                var attr =\n                    prop.GetCustomAttribute(typeof(ModTranslationPropAttribute)) as ModTranslationPropAttribute;\n\n                mappings.Add(attr.PropName, prop);\n            }\n\n            return mappings;\n        }\n\n        /// <summary>\n        ///     Get the translation of the property of the entry.\n        ///     eg: GetTranslation(*an ItemEntry*, *Name property*)\n        ///     which returns ItemEntry.Name.Translation.\n        /// </summary>\n        /// <param name=\"entry\"></param>\n        /// <param name=\"prop\"></param>\n        /// <returns></returns>\n        public static string GetTranslationOfEntry(IEntry entry, PropertyInfo prop)\n        {\n            return (prop.GetValue(entry) as BaseEntry)?.Translation;\n        }\n\n        /// <summary>\n        ///     Create directory if doesn't exist.\n        /// </summary>\n        /// <param name=\"path\"></param>\n        public static void EnsureDir(string path)\n        {\n            if (!Directory.Exists(path))\n            {\n                Directory.CreateDirectory(path);\n            }\n        }\n\n        public static ICollection<IMod> GetLoadedMods()\n        {\n            return ModLoader.Mods?.Select(m => Localizer.GetWrappedMod(m.Name)).ToArray();\n        }\n\n        public static Mod GetModByName(string name)\n        {\n            return ModLoader.Mods.FirstOrDefault(m => m.Name == name);\n        }\n\n        public static string DateTimeToFileName(DateTime dateTime)\n        {\n            return string.Format(\"{0:yyyy-MM-dd_hh-mm-ss-tt}\", dateTime);\n        }\n\n        public static string EscapePath(string path)\n        {\n            return path.Trim(Path.GetInvalidPathChars());\n        }\n\n        public static List<ILInstruction> GetInstructions(MethodBase method)\n        {\n            var dummy = new DynamicMethod(\"Dummy\", typeof(void), new Type[] { });\n            if (method.GetMethodBody() is null)\n            {\n                return null;\n            }\n            return MethodBodyReader.GetInstructions(dummy.GetILGenerator(), method);\n        }\n\n        public static void SafeWrap(Action action)\n        {\n            SafeWrap(action, out var ex);\n        }\n\n        public static void SafeWrap(Action action, out Exception ex)\n        {\n            try\n            {\n                ex = null;\n                action();\n            }\n            catch (Exception e)\n            {\n                ex = e;\n                LogError(e);\n            }\n        }\n\n        public static T SafeWrap<T>(Func<T> func)\n        {\n            return SafeWrap(func, out var ex);\n        }\n\n        public static T SafeWrap<T>(Func<T> func, out Exception ex)\n        {\n            try\n            {\n                ex = null;\n                return func();\n            }\n            catch (Exception e)\n            {\n                ex = e;\n                LogError(e);\n            }\n\n            return default;\n        }\n\n        public static void Patch(this HarmonyInstance instance, string @class, string method, bool exactMatch = true, HarmonyMethod prefix = null, HarmonyMethod postfix = null, HarmonyMethod transpiler = null)\n        {\n            if (exactMatch)\n            {\n                instance.Patch(@class.Type().Method(method),\n                    prefix: prefix,\n                    postfix: postfix,\n                    transpiler: transpiler);\n            }\n            else\n            {\n                instance.Patch(@class.Type()\n                    .GetMethods(NoroHelper.Any)\n                    .FirstOrDefault(m => m.Name.Contains(method)),\n                    prefix: prefix,\n                    postfix: postfix,\n                    transpiler: transpiler);\n            }\n        }\n        #endregion\n    }\n}\n"
  },
  {
    "path": "Localizer/Hooks.cs",
    "content": "using Microsoft.Xna.Framework;\n\nnamespace Localizer\n{\n    public class Hooks\n    {\n        public delegate void BeforeModCtorHandler(object mod);\n        public static event BeforeModCtorHandler BeforeModCtor;\n        internal static void InvokeBeforeModCtor(object mod)\n        {\n            BeforeModCtor?.Invoke(mod);\n        }\n\n        public delegate void BeforeLoadHandler();\n        public static event BeforeLoadHandler BeforeLoad;\n        internal static void InvokeBeforeLoad()\n        {\n            BeforeLoad?.Invoke();\n        }\n\n        public delegate void BeforeSetupContentHandler();\n        public static event BeforeSetupContentHandler BeforeSetupContent;\n        internal static void InvokeBeforeSetupContent()\n        {\n            BeforeSetupContent?.Invoke();\n        }\n\n        public delegate void PostSetupContentHandler();\n        public static event PostSetupContentHandler PostSetupContent;\n        internal static void InvokePostSetupContent()\n        {\n            PostSetupContent?.Invoke();\n        }\n\n        public delegate void GameUpdateHandler(GameTime gameTime);\n        public static event GameUpdateHandler GameUpdate;\n        internal static void InvokeOnGameUpdate(GameTime gameTime)\n        {\n            GameUpdate?.Invoke(gameTime);\n        }\n\n        public delegate void PostDrawHandler(GameTime gameTime);\n        public static event PostDrawHandler PostDraw;\n        internal static void InvokeOnPostDraw(GameTime gameTime)\n        {\n            PostDraw?.Invoke(gameTime);\n        }\n    }\n}\n"
  },
  {
    "path": "Localizer/Lang/Lang.cs",
    "content": "using System.Collections.Generic;\nusing Terraria.Localization;\nusing Terraria.ModLoader;\n\n// ReSharper disable once CheckNamespace\nnamespace Localizer\n{\n    public static class Lang\n    {\n        private static List<string> _keys = new List<string>()\n        {\n            \"NewVersion\",\n            \"PackageManage\",\n            \"Reload\",\n            \"ReloadDesc\",\n            \"OpenFolder\",\n            \"OpenFolderDesc\",\n            \"NoPackageFound\",\n            \"PackageEnabled\",\n            \"PackageDisabled\",\n            \"PackageDisplay\",\n            \"RefreshOnline\",\n            \"RefreshOnlineDesc\",\n            \"PackageOnline\",\n            \"Export\",\n            \"ExportDesc\",\n            \"ExportWithTranslation\",\n            \"ExportWithTranslationDesc\",\n            \"PackageUpdate\",\n            \"PackageLoading\",\n            \"OpenUI\",\n            \"TranslatedBy\"\n        };\n\n        private static Dictionary<string, string> _en = new Dictionary<string, string>()\n        {\n            { _keys[0], \"Found new version of Localizer: {0} \\nPlease go update it.\" },\n            { _keys[1], \"Package Management\" },\n            { _keys[2], \"Reload\" },\n            { _keys[3], \"Reload all packages\" },\n            { _keys[4], \"Open Localizer Folder\" },\n            { _keys[5], \"Find downloaded and exported packages\" },\n            { _keys[6], \"No localization package found for this Mod\" },\n            { _keys[7], \"Enabled\" },\n            { _keys[8], \"Disabled\" },\n            { _keys[9], \"({0}) {1} v{2} by {3}\" },\n            { _keys[10], \"Refresh\" },\n            { _keys[11], \"Refresh online package list\" },\n            { _keys[12], \"Online\" },\n            { _keys[13], \"Export\" },\n            { _keys[14], \"Export without current translation\" },\n            { _keys[15], \"Export T\" },\n            { _keys[16], \"Export with translation\" },\n            { _keys[17], \"New Version\" },\n            { _keys[18], \"Packages loading\" },\n            { _keys[19], \"{0}, Click to open {1} config\" },\n            { _keys[20], \"{0}, translated by {1}\" },\n        };\n\n        private static Dictionary<string, string> _zh = new Dictionary<string, string>()\n        {\n            { _keys[0], \"发现汉化者Mod有新版本: {0} \\n请前往更新。\" },\n            { _keys[1], \"汉化包管理\" },\n            { _keys[2], \"重新加载\" },\n            { _keys[3], \"重新读取所有汉化包\" },\n            { _keys[4], \"打开文件夹\" },\n            { _keys[5], \"查找下载、导出的汉化包及配置文件\" },\n            { _keys[6], \"你没有这个Mod的汉化包，\\n请下载或自己制作\" },\n            { _keys[7], \"已启用\" },\n            { _keys[8], \"未启用\" },\n            { _keys[9], \"({0}) {1} v{2} 作者:{3}\" },\n            { _keys[10], \"刷新\" },\n            { _keys[11], \"刷新在线汉化包列表\" },\n            { _keys[12], \"未下载\" },\n            { _keys[13], \"导出\" },\n            { _keys[14], \"导出不包含当前翻译的汉化包\" },\n            { _keys[15], \"导出翻译\" },\n            { _keys[16], \"导出包含翻译的汉化包\" },\n            { _keys[17], \"可更新\" },\n            { _keys[18], \"正在加载汉化包，请稍候查看或刷新\" },\n            { _keys[19], \"{0}，点击打开{1}设置界面\" },\n            { _keys[20], \"{0}，汉化：{1}\" },\n        };\n\n        public static void AddModTranslations(Mod mod)\n        {\n            foreach (var k in _keys)\n            {\n                var translation = mod.CreateTranslation(k);\n                translation.SetDefault(_en[k]);\n                translation.AddTranslation(GameCulture.Chinese, _zh[k]);\n                mod.AddTranslation(translation);\n            }\n        }\n\n        public static string _(string key, params object[] args)\n        {\n            var value = Language.GetTextValue($\"Mods.Localizer.{key}\");\n            if (value == $\"Mods.Localizer.{key}\")\n            {\n                value = Language.GetTextValue($\"Mods.!Localizer.{key}\");\n            }\n\n            return string.Format(value, args);\n        }\n    }\n}\n"
  },
  {
    "path": "Localizer/Localizer.cs",
    "content": "using System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.Net;\nusing System.Reflection;\nusing System.Threading.Tasks;\nusing Harmony;\nusing Localizer.Attributes;\nusing Localizer.DataModel;\nusing Localizer.DataModel.Default;\nusing Localizer.Helpers;\nusing Localizer.Network;\nusing Localizer.Package.Import;\nusing Localizer.UIs;\nusing log4net;\nusing Microsoft.Xna.Framework;\nusing MonoMod.RuntimeDetour.HookGen;\nusing Ninject;\nusing Terraria;\nusing Terraria.Localization;\nusing Terraria.ModLoader;\nusing Terraria.ModLoader.Core;\nusing static Localizer.Lang;\nusing File = System.IO.File;\n\nnamespace Localizer\n{\n    public sealed class Localizer : Mod\n    {\n        public static string SavePath;\n        public static string SourcePackageDirPath;\n        public static string DownloadPackageDirPath;\n        public static string ConfigPath;\n        public static Localizer Instance { get; private set; }\n        public static ILog Log { get; private set; }\n        public static TmodFile TmodFile { get; private set; }\n        public static Configuration Config { get; set; }\n        public static OperationTiming State { get; internal set; }\n        internal static LocalizerKernel Kernel { get; private set; }\n        internal static HarmonyInstance Harmony { get; set; }\n        internal static MainWindow PackageUI { get; set; }\n        internal static LoadedModWrapper LoadedLocalizer;\n\n        private static Dictionary<int, GameCulture> _gameCultures;\n\n        private static bool _initiated = false;\n\n        public Localizer()\n        {\n            Instance = this;\n            LoadedLocalizer = new LoadedModWrapper(\"Terraria.ModLoader.Core.AssemblyManager\".Type().ValueOf(\"loadedMods\").Invoke(\"get_Item\", \"!Localizer\"));\n            this.SetField(\"<File>k__BackingField\", LoadedLocalizer.File);\n            this.SetField(\"<Code>k__BackingField\", LoadedLocalizer.Code);\n            Log = LogManager.GetLogger(nameof(Localizer));\n\n            Harmony = HarmonyInstance.Create(nameof(Localizer));\n            Harmony.Patch(\"Terraria.ModLoader.Core.AssemblyManager\", \"Instantiate\",\n                prefix: NoroHelper.HarmonyMethod(() => AfterLocalizerCtorHook(null)));\n\n            State = OperationTiming.BeforeModCtor;\n            TmodFile = Instance.ValueOf<TmodFile>(\"File\");\n            Init();\n            _initiated = true;\n        }\n\n        private static void AfterLocalizerCtorHook(object mod)\n        {\n            Hooks.InvokeBeforeModCtor(mod);\n        }\n\n        private static void Init()\n        {\n            _gameCultures = typeof(GameCulture).ValueOf<Dictionary<int, GameCulture>>(\"_legacyCultures\");\n\n            ServicePointManager.ServerCertificateValidationCallback += (s, cert, chain, sslPolicyErrors) => true;\n            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;\n\n            SavePath = \"./Localizer/\";\n            SourcePackageDirPath = SavePath + \"/Source/\";\n            DownloadPackageDirPath = SavePath + \"/Download/\";\n            ConfigPath = SavePath + \"/Config.json\";\n\n            Utils.EnsureDir(SavePath);\n            Utils.EnsureDir(SourcePackageDirPath);\n            Utils.EnsureDir(DownloadPackageDirPath);\n\n            LoadConfig();\n            AddModTranslations(Instance);\n            Kernel = new LocalizerKernel();\n            Kernel.Init();\n\n            ModBrowser.Patches.Patch();\n\n            var autoImportService = Kernel.Get<AutoImportService>();\n        }\n\n        public override void Load()\n        {\n            if (!_initiated)\n            {\n                throw new Exception(\"Localizer not initialized.\");\n            }\n\n            State = OperationTiming.BeforeModLoad;\n            Hooks.InvokeBeforeLoad();\n            Kernel.Get<RefreshLanguageService>();\n\n            UIModsPatch.Patch();\n        }\n\n        public override void PostSetupContent()\n        {\n            State = OperationTiming.BeforeContentLoad;\n            Hooks.InvokeBeforeSetupContent();\n            CheckUpdate();\n            AddPostDrawHook();\n        }\n\n        public UIHost UIHost { get; private set; }\n        private void AddPostDrawHook()\n        {\n            if (Main.dedServ)\n            {\n                return;\n            }\n\n            UIHost = new UIHost();\n\n            Main.OnPostDraw += OnPostDraw;\n        }\n\n        private void OnPostDraw(GameTime time)\n        {\n            if (Main.dedServ)\n            {\n                return;\n            }\n\n            Main.spriteBatch.SafeBegin();\n            Hooks.InvokeOnPostDraw(time);\n            try\n            {\n                UIHost.Update(time);\n                UIHost.Draw(time);\n            }\n            catch\n            {\n            }\n\n            if (PackageUI?.Visible ?? false)\n            {\n                Main.DrawCursor(Main.DrawThickCursor(false), false);\n            }\n\n            Main.spriteBatch.SafeEnd();\n        }\n\n        public override void PostAddRecipes()\n        {\n            State = OperationTiming.PostContentLoad;\n\n            Hooks.InvokePostSetupContent();\n        }\n\n        public override void UpdateUI(GameTime gameTime)\n        {\n            Hooks.InvokeOnGameUpdate(gameTime);\n        }\n\n        public void CheckUpdate()\n        {\n            Task.Run(() =>\n            {\n                var curVersion = Version;\n                if (Kernel.Get<IUpdateService>().CheckUpdate(curVersion, out var updateInfo))\n                {\n                    var msg = _(\"NewVersion\", updateInfo.Version);\n                    if (Main.gameMenu)\n                    {\n                        UI.ShowInfoMessage(msg, 0);\n                    }\n                    else\n                    {\n                        Main.NewText(msg, Color.Red);\n                    }\n                }\n            });\n        }\n\n        public override void Unload()\n        {\n            try\n            {\n                SaveConfig();\n\n                // MonoModHooks.RemoveAll use mod.Name to unload the mod assembly\n                LoadedLocalizer.File.SetField(\"<name>k__BackingField\", \"!Localizer\");\n                LoadedLocalizer.SetField(\"name\", \"!Localizer\");\n\n                PackageUI?.Close();\n                UIHost.Dispose();\n                Main.OnPostDraw -= OnPostDraw;\n\n                HookEndpointManager.RemoveAllOwnedBy(this);\n                Harmony.UnpatchAll(nameof(Localizer));\n                Harmony.UnpatchAll(nameof(Patches));\n                Kernel.Dispose();\n\n                PackageUI = null;\n                Harmony = null;\n                Kernel = null;\n                _gameCultures = null;\n                Config = null;\n                Instance = null;\n            }\n            catch (Exception e)\n            {\n                Log.Error(e);\n            }\n            finally\n            {\n                _initiated = false;\n                Log = null;\n            }\n\n            base.Unload();\n        }\n\n        public static void LoadConfig()\n        {\n            Log.Info(\"Loading config\");\n            if (File.Exists(ConfigPath))\n            {\n                Config = Utils.ReadFileAndDeserializeJson<Configuration>(ConfigPath);\n                if (Config is null)\n                {\n                    Config = new Configuration();\n                }\n            }\n            else\n            {\n                Log.Info(\"No config file, creating...\");\n                Config = new Configuration();\n            }\n\n            Utils.SerializeJsonAndCreateFile(Config, ConfigPath);\n            Log.Info(\"Config loaded\");\n        }\n\n        public static void SaveConfig()\n        {\n            Log.Info(\"Saving config...\");\n            Utils.SerializeJsonAndCreateFile(Config, ConfigPath);\n            Log.Info(\"Config saved\");\n        }\n\n        public static GameCulture AddGameCulture(CultureInfo culture)\n        {\n            return GameCulture.FromName(culture.Name) != null\n                ? null\n                : new GameCulture(culture.Name, _gameCultures.Count);\n        }\n\n        public static GameCulture CultureInfoToGameCulture(CultureInfo culture)\n        {\n            var gc = GameCulture.FromName(culture.Name);\n            return gc ?? AddGameCulture(culture);\n        }\n\n        public static void RefreshLanguages()\n        {\n            Kernel.Get<RefreshLanguageService>().Refresh();\n        }\n\n        public static IMod GetWrappedMod(string name)\n        {\n            if (State < OperationTiming.PostContentLoad)\n            {\n                var loadedMods = \"Terraria.ModLoader.Core.AssemblyManager\".Type().ValueOf(\"loadedMods\");\n                return (bool)loadedMods.Invoke(\"ContainsKey\", name)\n                    ? new LoadedModWrapper(loadedMods.Invoke(\"get_Item\", name))\n                    : null;\n            }\n\n            var mod = Utils.GetModByName(name);\n            if (mod is null)\n            {\n                return null;\n            }\n\n            return new ModWrapper(mod);\n        }\n\n        public static bool CanDoOperationNow(Type t)\n        {\n            var attribute = t.GetCustomAttribute<OperationTimingAttribute>();\n            return attribute == null || CanDoOperationNow(attribute.Timing);\n        }\n\n        public static bool CanDoOperationNow(OperationTiming t)\n        {\n            return (t & State) != 0;\n        }\n    }\n}\n"
  },
  {
    "path": "Localizer/Localizer.csproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project Sdk=\"Microsoft.NET.Sdk\">\n  <Import Project=\"$(USERPROFILE)\\Documents\\My Games\\Terraria\\ModLoader\\references\\tModLoader.targets\" />\n  <PropertyGroup>\n    <AssemblyName>Localizer</AssemblyName>\n    <TargetFramework>net45</TargetFramework>\n    <PlatformTarget>x86</PlatformTarget>\n    <LangVersion>7.3</LangVersion>\n  </PropertyGroup>\n  <ItemGroup>\n    <PackageReference Include=\"Lib.Harmony\">\n      <Version>1.2.0.1</Version>\n    </PackageReference>\n    <PackageReference Include=\"Ninject\">\n      <Version>3.3.4</Version>\n    </PackageReference>\n    <PackageReference Include=\"tModLoader.CodeAssist\" Version=\"0.1.*\" />\n  </ItemGroup>\n  <ItemGroup>\n    <ProjectReference Include=\"..\\Squid\\Squid.csproj\">\n      <Project>{205c6e4a-4f9c-44fe-bb81-48f9914f048f}</Project>\n      <Name>Squid</Name>\n    </ProjectReference>\n  </ItemGroup>\n  <ItemGroup>\n    <Reference Include=\"System.IO.Compression\" />\n  </ItemGroup>\n  <Target Name=\"BuildMod\" AfterTargets=\"Build\">\n    <Exec Command=\"mkdir $(ProjectDir)lib\" Condition=\"!Exists('$(ProjectDir)lib')\" />\n    <Exec Command=\"copy $(OutDir)0Harmony.dll $(ProjectDir)lib\\0Harmony.dll\" />\n    <Exec Command=\"copy $(OutDir)Ninject.dll $(ProjectDir)lib\\Ninject.dll\" />\n    <Exec Command=\"copy $(OutDir)Squid.dll $(ProjectDir)lib\\Squid.dll\" />\n    <Exec Command=\"&quot;$(tMLBuildServerPath)&quot; -build $(ProjectDir) -eac $(TargetPath) -define $(DefineConstants) -unsafe $(AllowUnsafeBlocks)\" />\n    <Exec Command=\"$(SolutionDir)ModPatch\\bin\\Debug\\net472\\ModPatch.exe\" Condition=\" '$(Configuration)' == 'Debug' \" />\n    <Exec Command=\"$(SolutionDir)ModPatch\\bin\\Release\\net472\\ModPatch.exe\" Condition=\" '$(Configuration)' == 'Release' \" />\n  </Target>\n</Project>"
  },
  {
    "path": "Localizer/Localizer.csproj.DotSettings",
    "content": "﻿<wpf:ResourceDictionary xml:space=\"preserve\" xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\" xmlns:s=\"clr-namespace:System;assembly=mscorlib\" xmlns:ss=\"urn:shemas-jetbrains-com:settings-storage-xaml\" xmlns:wpf=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\">\n\t<s:Boolean x:Key=\"/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=enums/@EntryIndexedValue\">True</s:Boolean></wpf:ResourceDictionary>"
  },
  {
    "path": "Localizer/LocalizerKernel.cs",
    "content": "using System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Reflection;\nusing Localizer.Modules;\nusing Ninject;\nusing Ninject.Modules;\n\nnamespace Localizer\n{\n    public sealed class LocalizerKernel : StandardKernel\n    {\n        public List<LocalizerPlugin> Plugins { get; private set; }\n\n        public Dictionary<string, bool> PluginEnableStatus { get; private set; }\n\n        private static readonly string ExternalPluginDirPath = \"./Localizer/Plugins/\";\n\n        public LocalizerKernel()\n        {\n            AppDomain.CurrentDomain.AssemblyResolve += AssemblyResolveHandler;\n\n            Plugins = new List<LocalizerPlugin>();\n            PluginEnableStatus = new Dictionary<string, bool>();\n        }\n\n        public void Init()\n        {\n            Load(new NinjectModule[]\n            {\n                new DefaultPackageModule(),\n                new DefaultNetworkModule(),\n            });\n\n            LoadPlugins();\n        }\n\n        public override void Dispose(bool disposing)\n        {\n            if (!IsDisposed)\n            {\n                AppDomain.CurrentDomain.AssemblyResolve -= AssemblyResolveHandler;\n\n                if (disposing)\n                {\n                    UnloadAllPlugins();\n                    Plugins = null;\n                }\n            }\n            base.Dispose(disposing);\n        }\n\n        internal void UnloadAllPlugins()\n        {\n            foreach (var plugin in Plugins)\n            {\n                plugin.Dispose();\n            }\n\n            Plugins.Clear();\n        }\n\n        internal void LoadPlugins()\n        {\n            Utils.EnsureDir(ExternalPluginDirPath);\n\n            var dirInfo = new DirectoryInfo(ExternalPluginDirPath);\n            foreach (var file in dirInfo.GetFiles(\"*.dll\"))\n            {\n                var a = Assembly.Load(File.ReadAllBytes(file.FullName));\n                LoadPlugin(a);\n            }\n        }\n\n        internal void LoadPlugin(Assembly asm)\n        {\n            try\n            {\n                foreach (var type in asm.GetExportedTypes())\n                {\n                    if (type.IsSubclassOf(typeof(LocalizerPlugin)) && type.IsPublic && !type.IsAbstract)\n                    {\n                        var instance = (LocalizerPlugin)Activator.CreateInstance(type);\n                        Plugins.Add(instance);\n                        instance.Initialize(this);\n                        Utils.LogInfo($\"Plugin [{instance.Name}] loaded.\");\n                    }\n                }\n            }\n            catch (Exception e)\n            {\n                Utils.LogError($\"Error occured when loading Plugin [{asm.GetName()}]. \\nError: {e}\");\n            }\n        }\n\n        internal void UnloadPlugin(string pluginName)\n        {\n            if (string.IsNullOrWhiteSpace(pluginName))\n            {\n                throw new ArgumentException(nameof(pluginName));\n            }\n\n            var plugin = Plugins.SingleOrDefault(p => p.Name == pluginName)\n                ?? throw new Exception($\"Cannot find plugin [{pluginName}]\");\n\n            UnloadPlugin(plugin);\n        }\n\n        internal void UnloadPlugin(LocalizerPlugin plugin)\n        {\n            if (plugin is null)\n            {\n                Utils.LogWarn(\"Plugin cannot be unloaded because it's null\");\n                return;\n            }\n\n            if (Plugins.Contains(plugin))\n            {\n                Utils.LogWarn($\"Plugin [{plugin.Name}] doesn't exist\");\n                return;\n            }\n\n            plugin.Dispose();\n\n            Plugins.Remove(plugin);\n\n            Utils.LogInfo($\"Plugin [{plugin.Name}] successfully unloaded.\");\n        }\n\n        private static Assembly AssemblyResolveHandler(object sender, ResolveEventArgs args)\n        {\n            try\n            {\n                var asmName = new AssemblyName(args.Name);\n\n                if (asmName.Name == \"Localizer\")\n                {\n                    return Localizer.Instance.Code;\n                }\n\n                var referencedAsm = Assembly.GetExecutingAssembly().GetReferencedAssemblies()\n                                            .FirstOrDefault(a => a.Name.StartsWith($\"!Localizer_{asmName.Name}_\"));\n                if (referencedAsm != null)\n                {\n                    return Assembly.Load(referencedAsm);\n                }\n\n                var fileName = asmName.Name + \".dll\";\n\n                var asmFile = GetExternalPluginFileBytes(fileName);\n\n                if (asmFile != null && asmFile.Length != 0)\n                {\n                    return Assembly.Load(asmFile);\n                }\n\n                return null;\n            }\n            catch (Exception)\n            {\n                return null;\n            }\n        }\n\n        private static byte[] GetExternalPluginFileBytes(string fileName)\n        {\n            var path = Path.Combine(ExternalPluginDirPath, fileName);\n\n            if (!File.Exists(path))\n            {\n                return null;\n            }\n\n            return File.ReadAllBytes(path);\n        }\n    }\n}\n"
  },
  {
    "path": "Localizer/LocalizerPlugin.cs",
    "content": "﻿using System;\n\nnamespace Localizer\n{\n    public abstract class LocalizerPlugin : Disposable\n    {\n        public abstract string Name { get; }\n        public abstract string Author { get; }\n        public virtual Version Version => new Version();\n        public abstract string Description { get; }\n\n        public abstract void Initialize(LocalizerKernel kernel);\n    }\n}\n"
  },
  {
    "path": "Localizer/ModBrowser/Patches.cs",
    "content": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Net;\nusing System.Reflection;\nusing System.Reflection.Emit;\nusing System.Text.RegularExpressions;\nusing Harmony;\nusing Terraria.Localization;\nusing Terraria.ModLoader;\n\nnamespace Localizer.ModBrowser\n{\n    public static class Patches\n    {\n        public static HarmonyInstance HarmonyInstance { get; set; }\n\n        public static void Patch()\n        {\n            Utils.LogInfo($\"Patching ModBrowser, tML version: {ModLoader.version}\");\n\n            HarmonyInstance = HarmonyInstance.Create(nameof(Patches));\n\n            if (LanguageManager.Instance.ActiveCulture == GameCulture.Chinese)\n            {\n                try\n                {\n                    #region Download Mod List\n                    if (!string.IsNullOrEmpty(GetModListURL()))\n                    {\n                        HarmonyInstance.Patch(\"Terraria.ModLoader.UI.ModBrowser.UIModBrowser\", \"<PopulateModBrowser>\",\n                            exactMatch: false,\n                            transpiler: NoroHelper.HarmonyMethod(() => PopulateModBrowserTranspiler(null)));\n                        Utils.LogInfo(\"PopulateModBrowser Patched\");\n                    }\n                    #endregion\n\n                    #region Get Mod Download URL\n                    if (!string.IsNullOrEmpty(GetModDownloadURL()))\n                    {\n                        HarmonyInstance.Patch(\"Terraria.ModLoader.UI.ModBrowser.UIModDownloadItem\", \"FromJson\",\n                            transpiler: NoroHelper.HarmonyMethod(() => FromJSONTranspiler(null)));\n                        Utils.LogInfo(\"FromJson Patched\");\n\n                        if (!string.IsNullOrEmpty(GetModDescURL()))\n                        {\n                            HarmonyInstance.Patch(\"Terraria.ModLoader.UI.UIModInfo\", \"<OnActivate>\",\n                                exactMatch: false,\n                                transpiler: NoroHelper.HarmonyMethod(() => OnActivateTranspiler(null)));\n                            Utils.LogInfo(\"OnActivate Patched\");\n                        }\n                    }\n                    #endregion\n\n                    #region List My Mods\n                    // Terraria.ModLoader.UI.UIManagePublished.OnActivate\n                    // \"http://javid.ddns.net/tModLoader/listmymods.php\"\n                    #endregion\n\n                    #region Publish Mod\n                    // Terraria.ModLoader.UI.UIModSourceItem.PublishMod\n                    // \"http://javid.ddns.net/tModLoader/publishmod.php\"\n                    #endregion\n\n                    #region Unpublish Mod\n                    // Terraria.ModLoader.UI.UIModManageItem.UnpublishMod\n                    // \"http://javid.ddns.net/tModLoader/unpublishmymod.php\"\n                    #endregion\n\n                    #region Register Link\n                    // Terraria.ModLoader.UI.UIEnterPassphraseMenu.VisitRegisterWebpage\n                    // Terraria.ModLoader.UI.UIEnterSteamIDMenu.VisitRegisterWebpage\n                    // \"http://javid.ddns.net/tModLoader/register.php\"\n                    #endregion\n\n                    #region Direct Mod Listing\n                    // Terraria.ModLoader.UI.ModBrowser.UIModBrowser.<>c.<ShowOfflineTroubleshootingMessage>\n                    // \"http://javid.ddns.net/tModLoader/DirectModDownloadListing.php\"\n                    HarmonyInstance.Patch(\"Terraria.ModLoader.UI.ModBrowser.UIModBrowser.<>c\", \"<ShowOfflineTroubleshootingMessage>\",\n                        exactMatch: false,\n                        transpiler: NoroHelper.HarmonyMethod(() => DirectModListingTranspiler(null)));\n                    Utils.LogInfo(\"DirectModListing Patched\");\n                    #endregion\n\n                    #region Query Mod Download URL\n                    // Terraria.ModLoader.Interface.ServerModBrowserMenu\n                    // \"http://javid.ddns.net/tModLoader/tools/querymoddownloadurl.php?modname=\"\n                    #endregion\n\n                    #region Error Report\n                    // No plan\n                    #endregion\n\n                    #region ModCompile\n                    HarmonyInstance.Patch(\"Terraria.ModLoader.UI.UIDeveloperModeHelp\", \"DownloadModCompile\",\n                        transpiler: NoroHelper.HarmonyMethod(() => ModCompileTranspiler(null)));\n                    Utils.LogInfo(\"DownloadModCompile Patched\");\n                    #endregion\n\n                    #region Mod Update\n                    HarmonyInstance.Patch(\"Terraria.ModLoader.UI.DownloadManager.DownloadModFile\", \"PreCopy\",\n                        prefix: NoroHelper.HarmonyMethod(() => PreCopyPrefix(null)));\n                    Utils.LogInfo(\"PreCopy Patched\");\n                    #endregion\n\n                    Utils.LogInfo(\"ModBrowser Patched\");\n                }\n                catch (Exception e)\n                {\n                    Utils.LogInfo($\"ModBrowser Patch exception: {e}\");\n                }\n            }\n\n            try\n            {\n                HarmonyInstance.Patch(\"Terraria.ModLoader.UI.DownloadManager.DownloadFile\", \"SetupDownloadRequest\",\n                    postfix: NoroHelper.HarmonyMethod(() => PostSetupDownloadRequest(null)));\n                Utils.LogInfo(\"SetupDownloadRequest Patched\");\n            }\n            catch (Exception e)\n            {\n                Utils.LogInfo($\"ModBrowser Patch exception: {e}\");\n            }\n        }\n\n        private static readonly Regex _defaultMirror = new Regex(@\"mirror(?:\\d*)?\\.sgkoi\\.dev\");\n\n        private static string GetModListURL()\n        {\n            var mirror = Localizer.Config.ModListMirror[0];\n            switch (mirror)\n            {\n                case \"mirror2.sgkoi.dev\":\n                    return \"http://www.mb.axeel.moe/tModLoader/listmods.php\";\n                case \"mirror3.sgkoi.dev\":\n                    return \"https://trbbs.cc/trmod/listmods.php\";\n                case \"mirror4.sgkoi.dev\":\n                    return \"http://www.mb2.axeel.moe:25555/tModLoader/listmods.php\";\n                default:\n                    return _defaultMirror.IsMatch(mirror) ? $\"https://{mirror}/tModLoader/listmods.php\" : mirror;\n            }\n        }\n\n        private static string GetModDownloadURL()\n        {\n            var mirror = Localizer.Config.ModDownloadMirror[0];\n            switch (mirror)\n            {\n                case \"mirror2.sgkoi.dev\":\n                    return \"http://www.mb.axeel.moe/tModLoader/download.php?Down=mods/\";\n                case \"mirror3.sgkoi.dev\":\n                    return \"https://trbbs.cc/trmod/\";\n                case \"mirror4.sgkoi.dev\":\n                    return \"http://www.mb2.axeel.moe:25555/tModLoader/download.php?Down=mods/\";\n                default:\n                    return _defaultMirror.IsMatch(mirror) ? $\"https://{mirror}/tModLoader/download.php?Down=mods/\" : mirror;\n            }\n        }\n\n        private static string GetModDescURL()\n        {\n            var mirror = Localizer.Config.ModDescMirror[0];\n            switch (mirror)\n            {\n                case \"mirror2.sgkoi.dev\":\n                    return \"http://www.mb.axeel.moe/tModLoader/moddescription.php\";\n                case \"mirror4.sgkoi.dev\":\n                    return \"http://www.mb2.axeel.moe:25555/tModLoader/moddescription.php\";\n                default:\n                    return _defaultMirror.IsMatch(mirror) ? $\"https://{mirror}/tModLoader/moddescription.php\" : mirror;\n            }\n        }\n\n        private static void PreCopyPrefix(object ___ModBrowserItem)\n        {\n            if (___ModBrowserItem.ValueOf<string>(\"ModName\") == \"Localizer\")\n            {\n                ___ModBrowserItem.SetField(\"ModName\", \"!Localizer\");\n            }\n        }\n\n        private static void PostSetupDownloadRequest(object __instance)\n        {\n            var request = __instance.ValueOf<HttpWebRequest>(\"<Request>k__BackingField\");\n            request.UserAgent = Utils.UserAgent(false);\n            request.Headers[HttpRequestHeader.AcceptLanguage] = LanguageManager.Instance.ActiveCulture.CultureInfo.ToString();\n        }\n\n        public static void UpdateHeader(WebClient wc)\n        {\n            wc.Headers[HttpRequestHeader.UserAgent] = Utils.UserAgent(false);\n            wc.Headers[HttpRequestHeader.AcceptLanguage] = LanguageManager.Instance.ActiveCulture.CultureInfo.ToString();\n        }\n\n        private static IEnumerable<CodeInstruction> PopulateModBrowserTranspiler(IEnumerable<CodeInstruction> instructions)\n        {\n            var result = instructions.ToList();\n            ReplaceLdstr(\"http://javid.ddns.net/tModLoader/listmods.php\", GetModListURL(), result);\n            for (int i = 0; i < result.Count; i++)\n            {\n                if (result[i].opcode == OpCodes.Callvirt && $\"{result[i].operand}\".Contains(\"UploadValuesCompleted\"))\n                {\n                    result.Insert(i + 1, new CodeInstruction(result[i + 1]));\n                    result.Insert(i + 2, new CodeInstruction(OpCodes.Call, NoroHelper.MethodInfo(() => UpdateHeader(null))));\n                    break;\n                }\n            }\n\n            return result;\n        }\n\n        private static IEnumerable<CodeInstruction> FromJSONTranspiler(IEnumerable<CodeInstruction> instructions)\n        {\n            var result = instructions.ToList();\n            ReplaceLdstr(\"http://javid.ddns.net/tModLoader/download.php?Down=mods/\", GetModDownloadURL(), result);\n            ReplaceLdstr(\"&tls12=y\", \"\", result);\n\n            return result;\n        }\n\n        private static IEnumerable<CodeInstruction> OnActivateTranspiler(IEnumerable<CodeInstruction> instructions)\n        {\n            var result = instructions.ToList();\n            ReplaceLdstr(\"http://javid.ddns.net/tModLoader/download.php?Down=mods/\", GetModDownloadURL(), result);\n            ReplaceLdstr(\"http://javid.ddns.net/tModLoader/moddescription.php\", GetModDescURL(), result);\n            return result;\n        }\n\n        private static IEnumerable<CodeInstruction> DirectModListingTranspiler(IEnumerable<CodeInstruction> instructions)\n        {\n            var result = instructions.ToList();\n            ReplaceLdstr(\"http://javid.ddns.net/tModLoader/DirectModDownloadListing.php\", \"https://mirror.sgkoi.dev/\", result);\n\n            return result;\n        }\n\n        private static IEnumerable<CodeInstruction> ModCompileTranspiler(IEnumerable<CodeInstruction> instructions)\n        {\n            var result = instructions.ToList();\n            for (int i = 0; i < result.Count; i++)\n            {\n                if (result[i].opcode == OpCodes.Ldstr && $\"{result[i].operand}\" == \"https://github.com/tModLoader/tModLoader/releases/download/\")\n                {\n                    result[i].operand = \"https://mirror.sgkoi.dev/direct\";\n                    result[i + 1] = new CodeInstruction(OpCodes.Ldstr, \"\");\n                }\n            }\n\n            return result;\n        }\n\n        private static void ReplaceLdstr(string o, string n, IEnumerable<CodeInstruction> il)\n        {\n            var ins = il.FirstOrDefault(i => i?.operand?.ToString() == o);\n            if (ins != null)\n            {\n                ins.operand = n;\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "Localizer/Modules/DefaultNetworkModule.cs",
    "content": "using Localizer.Network;\nusing Ninject.Modules;\n\nnamespace Localizer.Modules\n{\n    public class DefaultNetworkModule : NinjectModule\n    {\n        public override void Load()\n        {\n            Bind<IPackageBrowserService>().To<PackageBrowser>().InSingletonScope();\n            Bind<IDownloadManagerService>().To<DownloadManager>().InSingletonScope();\n            Bind<IUpdateService>().To<GitHubModUpdate>().InSingletonScope();\n        }\n    }\n}\n"
  },
  {
    "path": "Localizer/Modules/DefaultPackageModule.cs",
    "content": "using System;\nusing System.Reflection;\nusing Localizer.DataModel;\nusing Localizer.DataModel.Default;\nusing Localizer.Package;\nusing Localizer.Package.Export;\nusing Localizer.Package.Import;\nusing Localizer.Package.Load;\nusing Localizer.Package.Pack;\nusing Localizer.Package.Save;\nusing Localizer.Package.Update;\nusing Ninject;\nusing Ninject.Modules;\n\nnamespace Localizer.Modules\n{\n    public class DefaultPackageModule : NinjectModule\n    {\n        public override void Load()\n        {\n            BindLoadService();\n            BindManageService();\n            BindImportService();\n            BindSaveService();\n            BindPackService();\n            BindExportService();\n            BindUpdateService();\n        }\n\n        public override void Unload()\n        {\n            Kernel.Get<AutoImportService>().Dispose();\n            Kernel.Get<RefreshLanguageService>().Dispose();\n            Kernel.Get<PackageImportService>().Dispose();\n        }\n\n        private void BindLoadService()\n        {\n            Bind<IFileLoadService>().To<JsonFileLoad>().InSingletonScope();\n\n            Bind<IPackageLoadService<DataModel.Default.Package>>()\n                .To<SourcePackageLoad<DataModel.Default.Package>>().InSingletonScope();\n            Bind<SourcePackageLoad<DataModel.Default.Package>>().ToSelf().InSingletonScope();\n\n            Bind<IPackageLoadService<DataModel.Default.Package>>()\n                .To<PackedPackageLoad<DataModel.Default.Package>>().InSingletonScope();\n            Bind<PackedPackageLoad<DataModel.Default.Package>>().ToSelf().InSingletonScope();\n        }\n\n        private void BindManageService()\n        {\n            Bind<IPackageManageService>().To<PackageManageService>();\n        }\n\n        private void BindImportService()\n        {\n            Bind<IPackageImportService>().To<PackageImportService>().InSingletonScope();\n\n            var packageImportService = Kernel.Get<IPackageImportService>();\n            if (Localizer.Config.ImporBasictAfterSetupContent)\n            {\n                packageImportService.RegisterImporter<BasicItemFile>(typeof(BasicImporterPostContentLoad<BasicItemFile>));\n                packageImportService.RegisterImporter<BasicNPCFile>(typeof(BasicImporterPostContentLoad<BasicNPCFile>));\n                packageImportService.RegisterImporter<BasicBuffFile>(typeof(BasicImporterPostContentLoad<BasicBuffFile>));\n                packageImportService.RegisterImporter<BasicProjectileFile>(typeof(BasicImporterPostContentLoad<BasicProjectileFile>));\n                packageImportService.RegisterImporter<BasicPrefixFile>(typeof(BasicImporterPostContentLoad<BasicPrefixFile>));\n            }\n            else\n            {\n                packageImportService.RegisterImporter<BasicItemFile>(typeof(BasicImporterBeforeContentLoad<BasicItemFile>));\n                packageImportService.RegisterImporter<BasicNPCFile>(typeof(BasicImporterBeforeContentLoad<BasicNPCFile>));\n                packageImportService.RegisterImporter<BasicBuffFile>(typeof(BasicImporterBeforeContentLoad<BasicBuffFile>));\n                packageImportService.RegisterImporter<BasicProjectileFile>(typeof(BasicImporterBeforeContentLoad<BasicProjectileFile>));\n                packageImportService.RegisterImporter<BasicPrefixFile>(typeof(BasicImporterBeforeContentLoad<BasicPrefixFile>));\n            }\n            packageImportService.RegisterImporter<CustomModTranslationFile>(typeof(CustomModTranslationImporter));\n            if (!string.IsNullOrWhiteSpace(Localizer.Config.LdstrImporter))\n            {\n                packageImportService.RegisterImporter<LdstrFile>(Assembly.GetExecutingAssembly().GetType($\"Localizer.Package.Import.{Localizer.Config.LdstrImporter}LdstrImporter\"));\n            }\n            else\n            {\n                packageImportService.RegisterImporter<LdstrFile>(typeof(CecilLdstrImporter));\n            }\n\n            Bind<AutoImportService>().ToSelf().InSingletonScope();\n            Bind<RefreshLanguageService>().ToSelf().InSingletonScope();\n        }\n\n        private void BindSaveService()\n        {\n            Bind<IPackageSaveService>().To<PackageSave>().InSingletonScope();\n            Bind<IFileSaveService>().To<JsonFileSaveService>().InSingletonScope();\n        }\n\n        private void BindPackService()\n        {\n            Bind<IPackagePackService>().To<ZipPackagePackService<DataModel.Default.Package>>().InSingletonScope();\n            Bind<ZipPackagePackService<DataModel.Default.Package>>().ToSelf().InSingletonScope();\n        }\n\n        private void BindExportService()\n        {\n            Bind<IPackageExportService>().To<PackageExport>().InSingletonScope();\n\n            Bind<IFileExportService>().To<BasicFileExport<BasicItemFile>>().InSingletonScope();\n            Bind<IFileExportService>().To<BasicFileExport<BasicNPCFile>>().InSingletonScope();\n            Bind<IFileExportService>().To<BasicFileExport<BasicBuffFile>>().InSingletonScope();\n            Bind<IFileExportService>().To<BasicFileExport<BasicProjectileFile>>().InSingletonScope();\n            Bind<IFileExportService>().To<BasicFileExport<BasicPrefixFile>>().InSingletonScope();\n            Bind<IFileExportService>().To<CustomModTranslationFileExport>().InSingletonScope();\n            Bind<IFileExportService>().To<LdstrFileExport>().InSingletonScope();\n        }\n\n        private void BindUpdateService()\n        {\n            void BindUpdate<T>(Type serviceType) where T : IFile\n            {\n                var updateService = Kernel.Get<IPackageUpdateService>();\n\n                Bind(typeof(FileUpdater), serviceType).To(serviceType).InSingletonScope();\n\n                updateService.RegisterUpdater<T>(Kernel.Get(serviceType) as FileUpdater);\n            }\n\n            Bind<IPackageUpdateService>().To<PackageUpdateService>().InSingletonScope();\n\n            BindUpdate<BasicItemFile>(typeof(BasicFileUpdater<BasicItemFile>));\n            BindUpdate<BasicNPCFile>(typeof(BasicFileUpdater<BasicNPCFile>));\n            BindUpdate<BasicBuffFile>(typeof(BasicFileUpdater<BasicBuffFile>));\n            BindUpdate<BasicProjectileFile>(typeof(BasicFileUpdater<BasicProjectileFile>));\n            BindUpdate<BasicPrefixFile>(typeof(BasicFileUpdater<BasicPrefixFile>));\n            BindUpdate<CustomModTranslationFile>(typeof(CustomModTranslationUpdater));\n            BindUpdate<LdstrFile>(typeof(LdstrFileUpdater));\n\n            Bind<IUpdateLogger>().To<PlainUpdateLogger>();\n        }\n    }\n}\n"
  },
  {
    "path": "Localizer/Network/DownloadManager.cs",
    "content": "using System;\nusing System.Net;\n\nnamespace Localizer.Network\n{\n    public class DownloadManager : IDownloadManagerService\n    {\n        public void Download(string url, string path)\n        {\n           var wc= new WebClient();\n            wc.Headers[HttpRequestHeader.UserAgent] = Utils.UserAgent();\n            wc.Headers[HttpRequestHeader.AcceptLanguage] = Terraria.Localization.LanguageManager.Instance.ActiveCulture.CultureInfo.ToString();\n            wc.DownloadFile(new Uri(url), path);\n        }\n\n        public void Dispose()\n        {\n        }\n    }\n}\n"
  },
  {
    "path": "Localizer/Network/GitHubModUpdate.cs",
    "content": "using System;\nusing System.Collections.Generic;\nusing Localizer.DataModel;\nusing Localizer.DataModel.Default;\nusing Newtonsoft.Json.Linq;\n\nnamespace Localizer.Network\n{\n    public sealed class GitHubModUpdate : IUpdateService\n    {\n        private JObject lastCheckResult;\n\n        public bool CheckUpdate(Version curVersion, out IUpdateInfo updateInfo)\n        {\n            var url = \"https://api.github.com/repos/chi-rei-den/Localizer/releases/latest\";\n\n            var response = Utils.GET(url);\n            lastCheckResult = JObject.Parse(Utils.GetResponseBody(response));\n\n            updateInfo = GetUpdateInfo(lastCheckResult);\n\n            if (updateInfo.Type == UpdateType.None)\n            {\n                return false;\n            }\n\n            return updateInfo.Version > curVersion;\n        }\n\n        internal GitHubUpdateInfo GetUpdateInfo(JObject jObject)\n        {\n            return new GitHubUpdateInfo(jObject[\"tag_name\"].ToObject<string>());\n        }\n\n        public Dictionary<Version, string> GetChangeLog(Version from, Version to)\n        {\n            throw new NotImplementedException();\n        }\n\n        public string GetDownloadURL()\n        {\n            return GetDownloadURLInternal(lastCheckResult);\n        }\n\n        internal string GetDownloadURLInternal(JObject jObject)\n        {\n            var assets = jObject[\"assets\"] as JArray;\n\n            if (assets == null || assets.Count == 0)\n            {\n                throw new Exception(\"Release has no assets!\");\n            }\n\n            return assets[0][\"browser_download_url\"].ToObject<string>();\n        }\n\n        public void Dispose()\n        {\n        }\n    }\n}\n"
  },
  {
    "path": "Localizer/Network/IDownloadManagerService.cs",
    "content": "namespace Localizer.Network\n{\n    public interface IDownloadManagerService\n    {\n        void Download(string url, string path);\n    }\n}\n"
  },
  {
    "path": "Localizer/Network/IPackageBrowserService.cs",
    "content": "using System.Collections.Generic;\nusing Localizer.DataModel;\n\nnamespace Localizer.Network\n{\n    public interface IPackageBrowserService\n    {\n        ICollection<IPackage> GetList();\n\n        int GetPageCount();\n\n        ICollection<IPackage> GetListByPage(int i);\n\n        string GetDownloadLinkOf(IPackage package);\n    }\n}\n"
  },
  {
    "path": "Localizer/Network/IUpdateService.cs",
    "content": "using System;\nusing System.Collections.Generic;\nusing Localizer.DataModel;\n\nnamespace Localizer.Network\n{\n    public interface IUpdateService\n    {\n        bool CheckUpdate(Version curVersion, out IUpdateInfo updateInfo);\n\n        Dictionary<Version, string> GetChangeLog(Version from, Version to);\n\n        string GetDownloadURL();\n    }\n}\n"
  },
  {
    "path": "Localizer/Network/PackageBrowser.cs",
    "content": "using System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing Localizer.DataModel;\nusing Newtonsoft.Json.Linq;\n\nnamespace Localizer.Network\n{\n    public class PackageBrowser : IPackageBrowserService\n    {\n#if DEBUG\n        public string serverURL = \"http://127.0.0.1:8000/api/\";\n#else\n        public string serverURL = \"https://mirror.sgkoi.dev/Localizer/\";\n#endif\n\n        private Dictionary<IPackage, int> packages = new Dictionary<IPackage, int>();\n\n        public ICollection<IPackage> GetList()\n        {\n            packages.Clear();\n\n            var result = new List<IPackage>();\n\n            var response = Utils.GET($\"{serverURL}List\");\n            var jArray = JArray.Parse(Utils.GetResponseBody(response));\n\n            foreach (JObject jo in jArray)\n            {\n                Utils.SafeWrap(() =>\n                {\n                    var pack = new DataModel.Default.Package()\n                    {\n                        Name = jo[\"name\"].ToObject<string>(),\n                        Author = jo[\"author\"].ToObject<string>(),\n                        Version = jo[\"version\"].ToObject<Version>(),\n                        ModName = jo[\"mod\"].ToObject<string>(),\n                        Language = jo[\"language\"].ToObject<CultureInfo>(),\n                        Description = jo[\"description\"].ToObject<string>(),\n                    };\n\n                    packages.Add(pack, jo[\"id\"].Value<int>());\n                    result.Add(pack);\n                });\n            }\n\n            return result;\n        }\n\n        public int GetPageCount()\n        {\n            throw new NotImplementedException();\n        }\n\n        public ICollection<IPackage> GetListByPage(int i)\n        {\n            throw new NotImplementedException();\n        }\n\n        public string GetDownloadLinkOf(IPackage package)\n        {\n            if (!packages.ContainsKey(package))\n            {\n                return null;\n            }\n\n            return $\"{serverURL}Download/{packages[package]}\";\n        }\n\n        public void Dispose()\n        {\n        }\n    }\n}\n"
  },
  {
    "path": "Localizer/Package/Export/BasicFileExport.cs",
    "content": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.Linq;\nusing System.Reflection;\nusing Localizer.DataModel;\nusing Localizer.DataModel.Default;\nusing Localizer.Helpers;\nusing Terraria.ModLoader;\n\nnamespace Localizer.Package.Export\n{\n    public sealed class BasicFileExport<T> : IFileExportService where T : IFile\n    {\n        public void Export(IPackage package, IExportConfig config)\n        {\n            var modName = package.ModName;\n            var mod = Utils.GetModByName(modName);\n\n            if (mod == null)\n            {\n                return;\n            }\n\n            var file = Activator.CreateInstance(typeof(T)) as IFile;\n\n            foreach (var prop in typeof(T).ModTranslationOwnerField())\n            {\n                var fieldName = prop.ModTranslationOwnerFieldName();\n\n                var field = mod.ValueOf<IDictionary>(fieldName);\n\n                var entryType = prop.PropertyType.GenericTypeArguments\n                                    .FirstOrDefault(g => g.GetInterfaces().Contains(typeof(IEntry)));\n\n                var entries = CreateEntries(field, entryType, package.Language, config.WithTranslation);\n\n                var entriesOfFile = (IDictionary)prop.GetValue(file);\n                foreach (var e in entries)\n                {\n                    entriesOfFile.Add(e.Key, e.Value);\n                }\n            }\n\n            package.AddFile(file);\n        }\n\n        private Dictionary<string, object> CreateEntries(IDictionary localizeOwners, Type entryType, CultureInfo lang,\n                                                         bool withTranslation)\n        {\n            var entries = new Dictionary<string, object>();\n\n            var mappings = Utils.CreateEntryMappings(entryType);\n\n            foreach (string key in localizeOwners.Keys)\n            {\n                var entry = Activator.CreateInstance(entryType);\n\n                foreach (var mapping in mappings)\n                {\n                    var owner = localizeOwners[key];\n                    var localizeTrans = owner?.GetType().GetProperty(mapping.Key)?.GetValue(owner) as ModTranslation;\n\n                    mapping.Value.SetValue(entry, new BaseEntry\n                    {\n                        Origin = localizeTrans.DefaultOrEmpty(),\n                        Translation = withTranslation ? localizeTrans?.GetTranslation(lang) : \"\"\n                    });\n                }\n\n                entries.Add(key, entry);\n            }\n\n            return entries;\n        }\n    }\n}\n"
  },
  {
    "path": "Localizer/Package/Export/CustomModTranslationFileExport.cs",
    "content": "using System.Collections.Generic;\nusing System.Reflection;\nusing Localizer.DataModel;\nusing Localizer.DataModel.Default;\nusing Localizer.Helpers;\nusing Terraria.ModLoader;\n\nnamespace Localizer.Package.Export\n{\n    public class CustomModTranslationFileExport : IFileExportService\n    {\n        public void Export(IPackage package, IExportConfig config)\n        {\n            if (package?.Mod == null)\n            {\n                return;\n            }\n\n            var translations = Utils.GetModByName(package.ModName).ValueOf<Dictionary<string, ModTranslation>>(\"translations\");\n\n            if (translations == null)\n            {\n                return;\n            }\n\n            var file = new CustomModTranslationFile\n            {\n                Translations = new Dictionary<string, BaseEntry>()\n            };\n\n            foreach (var translation in translations)\n            {\n                file.Translations.Add(translation.Key, new BaseEntry\n                {\n                    Origin = translation.Value.DefaultOrEmpty(),\n                    Translation = config.WithTranslation ? translation.Value?.GetTranslation(package.Language) : \"\"\n                });\n            }\n\n            package.AddFile(file);\n        }\n\n        public void Dispose()\n        {\n        }\n    }\n}\n"
  },
  {
    "path": "Localizer/Package/Export/IFileExportService.cs",
    "content": "using Localizer.DataModel;\n\nnamespace Localizer.Package.Export\n{\n    public interface IFileExportService\n    {\n        /// <summary>\n        ///     Extract texts from mod and add them into the package.\n        /// </summary>\n        /// <param name=\"package\"></param>\n        /// <param name=\"config\"></param>\n        void Export(IPackage package, IExportConfig config);\n    }\n}\n"
  },
  {
    "path": "Localizer/Package/Export/IPackageExportService.cs",
    "content": "using Localizer.DataModel;\n\nnamespace Localizer.Package.Export\n{\n    public interface IPackageExportService\n    {\n        /// <summary>\n        ///     Extract texts from the mod and fill up the package's file list.\n        /// </summary>\n        /// <param name=\"package\">Package with necessary information.</param>\n        /// <param name=\"config\"></param>\n        void Export(IPackage package, IExportConfig config);\n    }\n}\n"
  },
  {
    "path": "Localizer/Package/Export/LdstrFileExport.cs",
    "content": "using System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Reflection;\nusing Localizer.DataModel;\nusing Localizer.DataModel.Default;\nusing Mono.Cecil;\nusing MonoMod.Utils;\nusing Terraria.ModLoader;\nusing static Localizer.Utils;\nusing OpCodes = Mono.Cecil.Cil.OpCodes;\n\nnamespace Localizer.Package.Export\n{\n    public sealed class LdstrFileExport : IFileExportService\n    {\n        private static List<MethodBase> _blackList1 = new List<MethodBase>\n        {\n            GetMethodBase<ModTranslation>(\n                \"System.String Terraria.ModLoader.ModTranslation::GetTranslation(System.String)\"),\n            GetMethodBase<ModTranslation>(\n                \"System.Void Terraria.ModLoader.ModTranslation::AddTranslation(System.Int32,System.String)\"),\n            GetMethodBase<ModTranslation>(\n                \"System.Void Terraria.ModLoader.ModTranslation::AddTranslation(System.String,System.String)\"),\n            GetMethodBase<ModTranslation>(\n                \"System.Void Terraria.ModLoader.ModTranslation::AddTranslation(Terraria.Localization.GameCulture,System.String)\"),\n            GetMethodBase<Mod>(\n                \"Microsoft.Xna.Framework.Graphics.Texture2D Terraria.ModLoader.Mod::GetTexture(System.String)\"),\n            GetMethodBase<Mod>(\n                \"Microsoft.Xna.Framework.Audio.SoundEffect Terraria.ModLoader.Mod::GetSound(System.String)\"),\n            GetMethodBase<Mod>(\"Terraria.ModLoader.Audio.Music Terraria.ModLoader.Mod::GetMusic(System.String)\"),\n            GetMethodBase<Mod>(\"ReLogic.Graphics.DynamicSpriteFont Terraria.ModLoader.Mod::GetFont(System.String)\"),\n            GetMethodBase<Mod>(\n                \"Microsoft.Xna.Framework.Graphics.Effect Terraria.ModLoader.Mod::GetEffect(System.String)\"),\n            GetMethodBase<Mod>(\n                \"Terraria.ModLoader.Config.ModConfig Terraria.ModLoader.Mod::GetConfig(System.String)\"),\n            GetMethodBase<Mod>(\n                \"Terraria.ModLoader.GlobalProjectile Terraria.ModLoader.Mod::GetGlobalProjectile(System.String)\"),\n            GetMethodBase<Mod>(\"Terraria.ModLoader.ModNPC Terraria.ModLoader.Mod::GetNPC(System.String)\"),\n            GetMethodBase<Mod>(\"System.Int32 Terraria.ModLoader.Mod::NPCType(System.String)\"),\n            GetMethodBase<Mod>(\"Terraria.ModLoader.GlobalNPC Terraria.ModLoader.Mod::GetGlobalNPC(System.String)\"),\n            GetMethodBase<Mod>(\"Terraria.ModLoader.ModPlayer Terraria.ModLoader.Mod::GetPlayer(System.String)\"),\n            GetMethodBase<Mod>(\"Terraria.ModLoader.ModBuff Terraria.ModLoader.Mod::GetBuff(System.String)\"),\n            GetMethodBase<Mod>(\"System.Int32 Terraria.ModLoader.Mod::BuffType(System.String)\"),\n            GetMethodBase<Mod>(\n                \"Terraria.ModLoader.GlobalBuff Terraria.ModLoader.Mod::GetGlobalBuff(System.String)\"),\n            GetMethodBase<Mod>(\"Terraria.ModLoader.ModMountData Terraria.ModLoader.Mod::GetMount(System.String)\"),\n            GetMethodBase<Mod>(\"System.Int32 Terraria.ModLoader.Mod::MountType(System.String)\"),\n            GetMethodBase<Mod>(\"Terraria.ModLoader.ModWorld Terraria.ModLoader.Mod::GetModWorld(System.String)\"),\n            GetMethodBase<Mod>(\n                \"Terraria.ModLoader.ModUgBgStyle Terraria.ModLoader.Mod::GetUgBgStyle(System.String)\"),\n            GetMethodBase<Mod>(\n                \"Terraria.ModLoader.ModSurfaceBgStyle Terraria.ModLoader.Mod::GetSurfaceBgStyle(System.String)\"),\n            GetMethodBase<Mod>(\"System.Int32 Terraria.ModLoader.Mod::GetSurfaceBgStyleSlot(System.String)\"),\n            GetMethodBase<Mod>(\n                \"Terraria.ModLoader.GlobalBgStyle Terraria.ModLoader.Mod::GetGlobalBgStyle(System.String)\"),\n            GetMethodBase<Mod>(\n                \"Terraria.ModLoader.ModWaterStyle Terraria.ModLoader.Mod::GetWaterStyle(System.String)\"),\n            GetMethodBase<Mod>(\n                \"Terraria.ModLoader.ModWaterfallStyle Terraria.ModLoader.Mod::GetWaterfallStyle(System.String)\"),\n            GetMethodBase<Mod>(\"System.Int32 Terraria.ModLoader.Mod::GetWaterfallStyleSlot(System.String)\"),\n            GetMethodBase<Mod>(\"System.Int32 Terraria.ModLoader.Mod::GetGoreSlot(System.String)\"),\n            GetMethodBase<Mod>(\"System.Void Terraria.ModLoader.Mod::AddBackgroundTexture(System.String)\"),\n            GetMethodBase<Mod>(\"System.Int32 Terraria.ModLoader.Mod::GetBackgroundSlot(System.String)\"),\n            GetMethodBase<Mod>(\n                \"Terraria.ModLoader.ModTranslation Terraria.ModLoader.Mod::CreateTranslation(System.String)\"),\n            GetMethodBase<Mod>(\"System.Byte[] Terraria.ModLoader.Mod::GetFileBytes(System.String)\"),\n            GetMethodBase<Mod>(\"Terraria.ModLoader.ModItem Terraria.ModLoader.Mod::GetItem(System.String)\"),\n            GetMethodBase<Mod>(\"System.Int32 Terraria.ModLoader.Mod::ItemType(System.String)\"),\n            GetMethodBase<Mod>(\n                \"Terraria.ModLoader.GlobalItem Terraria.ModLoader.Mod::GetGlobalItem(System.String)\"),\n            GetMethodBase<Mod>(\"Terraria.ModLoader.ModPrefix Terraria.ModLoader.Mod::GetPrefix(System.String)\"),\n            GetMethodBase<Mod>(\"System.Byte Terraria.ModLoader.Mod::PrefixType(System.String)\"),\n            GetMethodBase<Mod>(\"Terraria.ModLoader.ModDust Terraria.ModLoader.Mod::GetDust(System.String)\"),\n            GetMethodBase<Mod>(\"System.Int32 Terraria.ModLoader.Mod::DustType(System.String)\"),\n            GetMethodBase<Mod>(\"Terraria.ModLoader.ModTile Terraria.ModLoader.Mod::GetTile(System.String)\"),\n            GetMethodBase<Mod>(\"System.Int32 Terraria.ModLoader.Mod::TileType(System.String)\"),\n            GetMethodBase<Mod>(\n                \"Terraria.ModLoader.GlobalTile Terraria.ModLoader.Mod::GetGlobalTile(System.String)\"),\n            GetMethodBase<Mod>(\n                \"Terraria.ModLoader.ModTileEntity Terraria.ModLoader.Mod::GetTileEntity(System.String)\"),\n            GetMethodBase<Mod>(\"System.Int32 Terraria.ModLoader.Mod::TileEntityType(System.String)\"),\n            GetMethodBase<Mod>(\"Terraria.ModLoader.ModWall Terraria.ModLoader.Mod::GetWall(System.String)\"),\n            GetMethodBase<Mod>(\"System.Int32 Terraria.ModLoader.Mod::WallType(System.String)\"),\n            GetMethodBase<Mod>(\n                \"Terraria.ModLoader.GlobalWall Terraria.ModLoader.Mod::GetGlobalWall(System.String)\"),\n            GetMethodBase<Mod>(\n                \"Terraria.ModLoader.ModProjectile Terraria.ModLoader.Mod::GetProjectile(System.String)\"),\n            GetMethodBase<Mod>(\"System.Int32 Terraria.ModLoader.Mod::ProjectileType(System.String)\"),\n            typeof(ModContent).FindMethod(\n                \"Microsoft.Xna.Framework.Audio.SoundEffect Terraria.ModLoader.ModContent::GetSound(System.String)\"),\n            typeof(ModContent).FindMethod(\"System.Byte[] Terraria.ModLoader.ModContent::GetFileBytes(System.String)\"),\n            typeof(ModContent).FindMethod(\"System.Boolean Terraria.ModLoader.ModContent::FileExists(System.String)\"),\n            typeof(ModContent).FindMethod(\n                \"Microsoft.Xna.Framework.Graphics.Texture2D Terraria.ModLoader.ModContent::GetTexture(System.String)\"),\n            typeof(ModContent).FindMethod(\"System.Boolean Terraria.ModLoader.ModContent::TextureExists(System.String)\"),\n            typeof(ModContent).FindMethod(\n                \"Microsoft.Xna.Framework.Audio.SoundEffect Terraria.ModLoader.ModContent::GetSound(System.String)\"),\n            typeof(ModContent).FindMethod(\"System.Boolean Terraria.ModLoader.ModContent::SoundExists(System.String)\"),\n            typeof(ModContent).FindMethod(\n                \"Terraria.ModLoader.Audio.Music Terraria.ModLoader.ModContent::GetMusic(System.String)\"),\n            typeof(ModContent).FindMethod(\"System.Boolean Terraria.ModLoader.ModContent::MusicExists(System.String)\"),\n            typeof(ModContent).FindMethod(\n                \"System.Int32 Terraria.ModLoader.ModContent::GetModBossHeadSlot(System.String)\"),\n            typeof(ModContent).FindMethod(\"System.Int32 Terraria.ModLoader.ModContent::GetModHeadSlot(System.String)\"),\n            typeof(ModContent).FindMethod(\n                \"System.Int32 Terraria.ModLoader.ModContent::GetModBackgroundSlot(System.String)\"),\n            typeof(ModContent).FindMethod(\"System.Boolean Terraria.ModLoader.ModContent::SoundExists(System.String)\"),\n            typeof(ModContent).FindMethod(\"System.Boolean Terraria.ModLoader.ModContent::SoundExists(System.String)\"),\n            typeof(ModContent).FindMethod(\"System.Boolean Terraria.ModLoader.ModContent::SoundExists(System.String)\"),\n            GetMethodBase<ModRecipe>(\n                \"System.Void Terraria.ModLoader.ModRecipe::AddTile(Terraria.ModLoader.Mod,System.String)\"),\n            typeof(ModLoader).FindMethod(\"Terraria.ModLoader.Mod Terraria.ModLoader.ModLoader::GetMod(System.String)\"),\n        };\n\n        private static List<MethodBase> _blackList2 = new List<MethodBase>\n        {\n            GetMethodBase<ModRecipe>(\n                \"System.Void Terraria.ModLoader.ModRecipe::AddIngredient(Terraria.ModLoader.Mod,System.String,System.Int32)\"),\n        };\n\n        public void Export(IPackage package, IExportConfig config)\n        {\n            if (package?.Mod == null)\n            {\n                return;\n            }\n\n            var modFile = package.Mod.File;\n            var asmManager = \"Terraria.ModLoader.Core.AssemblyManager\".Type();\n            var assemblyName = (string)asmManager.Invoke(\"GetModAssemblyFileName\", modFile, true);\n            var loadedMod = asmManager.ValueOf(\"loadedMods\").Invoke(\"get_Item\", package.Mod.Name);\n            var reref = (byte[])asmManager.GetNestedType(\"LoadedMod\", NoroHelper.Any).Method(\"EncapsulateReferences\")\n                .Invoke(loadedMod, new object[] { modFile.GetBytes(assemblyName), null });\n            var asm = AssemblyDefinition.ReadAssembly(new MemoryStream(reref));\n\n            var file = new LdstrFile\n            {\n                LdstrEntries = new Dictionary<string, LdstrEntry>()\n            };\n\n            foreach (var type in asm.MainModule.GetTypes())\n            {\n                if (type.Namespace == null)\n                {\n                    continue;\n                }\n\n                foreach (var method in type.Methods)\n                {\n                    if (method.DeclaringType?.Namespace == null || method.IsAbstract)\n                    {\n                        continue;\n                    }\n\n                    try\n                    {\n                        LogDebug($\"Exporting method: [{method.GetID()}]\");\n                        var entry = GetEntryFromMethod(method);\n                        if (entry != null && !file.LdstrEntries.ContainsKey(method.GetID()))\n                        {\n                            file.LdstrEntries.Add(method.GetID(), entry);\n                        }\n                    }\n                    catch (Exception e)\n                    {\n                        Localizer.Log.Error(e.ToString());\n                    }\n                }\n            }\n\n            package.AddFile(file);\n        }\n\n        private LdstrEntry GetEntryFromMethod(MethodDefinition method)\n        {\n            var instructions = method?.Body?.Instructions;\n\n            if (instructions == null)\n            {\n                return null;\n            }\n\n            var entry = new LdstrEntry { Instructions = new List<BaseEntry>() };\n            for (var i = 0; i < instructions.Count; i++)\n            {\n                var ins = instructions[i];\n                if (ins.OpCode == OpCodes.Ldstr && !string.IsNullOrWhiteSpace(ins.Operand.ToString()))\n                {\n                    // Filter methods in blacklist1\n                    if (i < instructions.Count - 1)\n                    {\n                        var next = instructions[i + 1];\n                        var operandId = \"\";\n                        if (next.OpCode == OpCodes.Call || next.OpCode == OpCodes.Callvirt)\n                        {\n                            operandId = (next.Operand as MethodReference).GetID();\n                        }\n                        else if (next.OpCode == OpCodes.Calli)\n                        {\n                            operandId = (next.Operand as CallSite).GetID();\n                        }\n\n                        if (!string.IsNullOrWhiteSpace(operandId) && _blackList1.Any(m => operandId == m?.GetID()))\n                        {\n                            continue;\n                        }\n                    }\n\n                    // Filter methods in blacklist2\n                    if (i < instructions.Count - 2)\n                    {\n                        var afterNext = instructions[i + 2];\n                        var operandId = \"\";\n                        if (afterNext.OpCode == OpCodes.Call || afterNext.OpCode == OpCodes.Callvirt)\n                        {\n                            operandId = (afterNext.Operand as MethodReference).GetID();\n                        }\n                        else if (afterNext.OpCode == OpCodes.Calli)\n                        {\n                            operandId = (afterNext.Operand as CallSite).GetID();\n                        }\n\n                        if (!string.IsNullOrWhiteSpace(operandId) && _blackList2.Any(m => operandId == m?.GetID()))\n                        {\n                            continue;\n                        }\n                    }\n\n                    // No need to add a same string\n                    if (entry.Instructions.Exists(e => e.Origin == ins.Operand.ToString()))\n                    {\n                        continue;\n                    }\n\n                    entry.Instructions.Add(new BaseEntry\n                    {\n                        Origin = ins.Operand.ToString(),\n                        Translation = \"\"\n                    });\n                }\n            }\n\n            return entry.Instructions.Count == 0 ? null : entry;\n        }\n\n        public void Dispose()\n        {\n            _blackList1 = null;\n            _blackList2 = null;\n        }\n    }\n}\n"
  },
  {
    "path": "Localizer/Package/Export/PackageExport.cs",
    "content": "using Localizer.DataModel;\nusing Ninject;\nusing Terraria.ModLoader;\n\nnamespace Localizer.Package.Export\n{\n    public class PackageExport : IPackageExportService\n    {\n        public void Export(IPackage package, IExportConfig config)\n        {\n            var fileExportServices = Localizer.Kernel.GetAll<IFileExportService>();\n\n            if (package.Mod == null || package.Mod.GetType() != typeof(Mod))\n            {\n                package.Mod = Localizer.GetWrappedMod(package.ModName);\n            }\n\n            foreach (var service in fileExportServices)\n            {\n                service.Export(package, config);\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "Localizer/Package/IPackageManageService.cs",
    "content": "using System.Collections.Generic;\nusing Localizer.DataModel;\n\nnamespace Localizer.Package\n{\n    public interface IPackageManageService\n    {\n        /// <summary>\n        ///     All added packages sorted by mod.\n        /// </summary>\n        ICollection<IPackageGroup> PackageGroups { get; set; }\n\n        /// <summary>\n        ///     Add a package.\n        /// </summary>\n        /// <param name=\"package\"></param>\n        void AddPackage(IPackage package);\n\n        /// <summary>\n        ///     Remove a package.\n        /// </summary>\n        /// <param name=\"package\"></param>\n        void RemovePackage(IPackage package);\n\n        /// <summary>\n        ///     Load saved package state.\n        /// </summary>\n        void LoadState();\n\n        /// <summary>\n        ///     Save the package state.\n        /// </summary>\n        void SaveState();\n    }\n}\n"
  },
  {
    "path": "Localizer/Package/Import/AutoImportService.cs",
    "content": "using System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing Localizer.DataModel;\nusing Localizer.DataModel.Default;\nusing Localizer.Helpers;\nusing Localizer.Package.Load;\nusing Localizer.Package.Pack;\nusing Localizer.UIs;\nusing Ninject;\n\nusing PackageModel = Localizer.DataModel.Default.Package;\n\nnamespace Localizer.Package.Import\n{\n    public sealed class AutoImportService : Disposable\n    {\n        public bool Imported => _imported;\n\n        private readonly IPackageManageService _packageManage;\n        private readonly SourcePackageLoad<PackageModel> _sourcePackageLoad;\n        private readonly PackedPackageLoad<PackageModel> _packedPackageLoad;\n        private readonly IPackageImportService _packageImport;\n        private readonly IPackagePackService _packagePack;\n        private readonly IFileLoadService _fileLoad;\n\n        private bool _imported = false;\n\n        [Inject]\n        public AutoImportService(IPackageManageService packageManage,\n                                 SourcePackageLoad<PackageModel> sourcePackageLoad,\n                                 PackedPackageLoad<PackageModel> packedPackageLoad,\n                                 IPackageImportService packageImport,\n                                 IPackagePackService packagePack,\n                                 IFileLoadService fileLoad)\n        {\n            _packageManage = packageManage ?? throw new ArgumentNullException(nameof(packageManage));\n            _sourcePackageLoad = sourcePackageLoad ?? throw new ArgumentNullException(nameof(sourcePackageLoad));\n            _packedPackageLoad = packedPackageLoad ?? throw new ArgumentNullException(nameof(packedPackageLoad));\n            _packageImport = packageImport ?? throw new ArgumentNullException(nameof(packageImport));\n            _packagePack = packagePack ?? throw new ArgumentNullException(nameof(packagePack));\n            _fileLoad = fileLoad ?? throw new ArgumentNullException(nameof(fileLoad));\n            LoadPackages();\n\n            Hooks.BeforeModCtor += OnBeforeModCtor;\n            Hooks.PostSetupContent += OnPostSetupContent;\n        }\n\n        private void OnBeforeModCtor(object mod)\n        {\n            if (_imported)\n            {\n                return;\n            }\n\n            try\n            {\n                if (Localizer.Config.AutoImport)\n                {\n                    var wrapped = new LoadedModWrapper(mod);\n                    Utils.LogInfo($\"Early auto import for mod: [{wrapped.Name}]\");\n                    Import(wrapped);\n                }\n            }\n            catch\n            {\n            }\n        }\n\n        private void OnPostSetupContent()\n        {\n            if (_imported)\n            {\n                return;\n            }\n\n            try\n            {\n                if (Localizer.Config.AutoImport)\n                {\n                    Utils.LogInfo($\"Late auto import begin.\");\n                    Import();\n                }\n            }\n            catch (Exception e)\n            {\n                Utils.LogError(e);\n            }\n            finally\n            {\n                _imported = true;\n            }\n        }\n\n        private void LoadPackages()\n        {\n            try\n            {\n                _packageManage.PackageGroups = new List<IPackageGroup>();\n\n                var type = Localizer.Config.AutoImportType;\n\n                if (type != AutoImportType.DownloadedOnly)\n                {\n                    LoadSourcePackages();\n                }\n\n                if (type != AutoImportType.SourceOnly)\n                {\n                    LoadPackedPackages();\n                }\n\n                _packageManage.LoadState();\n\n                UIModsPatch.ModsExtraInfo = _packageManage.PackageGroups.ToDictionary(group => group.Mod.Name,\n                     group =>\n                     {\n                         var localizedModName = group.Packages.FirstOrDefault(pack => !string.IsNullOrWhiteSpace(pack.LocalizedModName))?.LocalizedModName;\n                         return $\"{localizedModName}{Environment.NewLine}{string.Join(Environment.NewLine, group.Packages.Select(UI.GetPkgLabelText))}\";\n                     });\n            }\n            catch (Exception e)\n            {\n                Utils.LogError(e);\n            }\n        }\n\n        private void LoadSourcePackages()\n        {\n            foreach (var dir in new DirectoryInfo(Localizer.SourcePackageDirPath).GetDirectories())\n            {\n                try\n                {\n                    var pack = _sourcePackageLoad.Load(dir.FullName, _fileLoad);\n                    if (pack != null)\n                    {\n                        _packageManage.AddPackage(pack);\n                        _packagePack.Pack(Path.Combine(dir.FullName, \"Package.json\"));\n                    }\n                }\n                catch\n                {\n                }\n            }\n        }\n\n        private void LoadPackedPackages()\n        {\n            var list = Directory.GetFiles(Localizer.DownloadPackageDirPath).ToList();\n            list.AddRange(Directory.GetFiles(Path.Combine(Terraria.Main.SavePath, \"Mods\"), \"*.locpack\"));\n            foreach (var file in list)\n            {\n                try\n                {\n                    var pack = _packedPackageLoad.Load(file, _fileLoad);\n                    if (pack != null)\n                    {\n                        _packageManage.AddPackage(pack);\n                    }\n                }\n                catch\n                {\n                }\n            }\n        }\n\n        private void Import(IMod mod = null)\n        {\n            try\n            {\n                _packageImport.Clear();\n\n                if (mod is null)\n                {\n                    foreach (var pg in _packageManage.PackageGroups)\n                    {\n                        QueuePackageGroup(pg);\n                    }\n                }\n                else\n                {\n                    QueuePackageGroup(_packageManage.PackageGroups.FirstOrDefault(pg => pg.Mod.Name == mod.Name));\n                }\n\n                _packageImport.Import(true);\n\n                Localizer.RefreshLanguages();\n\n                Utils.LogDebug(\"Auto import end.\");\n            }\n            catch\n            {\n            }\n        }\n\n        private void QueuePackageGroup(IPackageGroup packageGroup)\n        {\n            if (packageGroup is null || !packageGroup.Mod.Enabled)\n            {\n                return;\n            }\n\n            foreach (var p in packageGroup.Packages)\n            {\n                if (p.Enabled)\n                {\n                    _packageImport.Queue(p);\n                }\n            }\n        }\n\n        protected override void DisposeUnmanaged()\n        {\n            Hooks.PostSetupContent -= OnPostSetupContent;\n            Hooks.BeforeModCtor -= OnBeforeModCtor;\n        }\n    }\n}\n"
  },
  {
    "path": "Localizer/Package/Import/BasicImporter.cs",
    "content": "using System;\nusing System.Collections;\nusing System.Globalization;\nusing System.Linq;\nusing System.Reflection;\nusing Localizer.Attributes;\nusing Localizer.DataModel;\nusing Localizer.DataModel.Default;\nusing Localizer.Helpers;\nusing Terraria.ModLoader;\n\nnamespace Localizer.Package.Import\n{\n    public class BasicImporter<T> : FileImporter where T : IFile\n    {\n        public override void Import(IFile file, IMod mod, CultureInfo culture)\n        {\n            ImportInternal((T)file, mod, culture);\n        }\n\n        private void ImportInternal(T file, IMod mod, CultureInfo culture)\n        {\n            foreach (var prop in typeof(T).ModTranslationOwnerField())\n            {\n                var fieldName = prop.ModTranslationOwnerFieldName();\n\n                var field = Utils.GetModByName(mod.Name).ValueOf<IDictionary>(fieldName);\n\n                var entryType = prop.PropertyType.GenericTypeArguments\n                                    .FirstOrDefault(g => g.GetInterfaces().Contains(typeof(IEntry)));\n\n                var entries = (IDictionary)prop.GetValue(file);\n\n                ApplyEntries(entries, field, entryType, culture);\n            }\n        }\n\n        public override IFile Merge(IFile main, IFile addition)\n        {\n            return MergeInternal((T)main, (T)addition);\n        }\n\n        internal T MergeInternal(T main, T addition)\n        {\n            var result = Activator.CreateInstance(typeof(T));\n\n            foreach (var prop in typeof(T).ModTranslationOwnerField())\n            {\n                var entries = (IDictionary)Activator.CreateInstance(prop.PropertyType);\n\n                var mainEntryDict = (IDictionary)prop.GetValue(main);\n                var additionEntryDict = (IDictionary)prop.GetValue(addition);\n\n                foreach (string key in mainEntryDict.Keys)\n                {\n                    entries.Add(key, (mainEntryDict[key] as IEntry)?.Clone());\n                }\n\n                foreach (string key in additionEntryDict.Keys)\n                {\n                    if (entries.Contains(key))\n                    {\n                        entries[key] = Merge((IEntry)mainEntryDict[key], (IEntry)additionEntryDict[key]);\n                    }\n                    else\n                    {\n                        entries.Add(key, additionEntryDict[key]);\n                    }\n                }\n\n                prop.SetValue(result, entries);\n            }\n\n            return (T)result;\n        }\n\n        public IEntry Merge(IEntry main, IEntry addition)\n        {\n            if (main.GetType() != addition.GetType())\n            {\n                return main;\n            }\n\n            var result = Activator.CreateInstance(main.GetType()) as IEntry;\n\n            var props = result.GetType().ModTranslationProp();\n\n            foreach (var prop in props)\n            {\n                var merged = Utils.GetTranslationOfEntry(main, prop);\n                if (string.IsNullOrEmpty(merged))\n                {\n                    merged = Utils.GetTranslationOfEntry(addition, prop) ?? \"\";\n                }\n                var baseEntry = Activator.CreateInstance(prop.PropertyType) as BaseEntry;\n                baseEntry.Translation = merged;\n                prop.SetValue(result, baseEntry);\n            }\n\n            return result;\n        }\n\n        private void ApplyEntries(IDictionary entries, IDictionary field, Type entryType, CultureInfo culture)\n        {\n            var mappings = Utils.CreateEntryMappings(entryType);\n\n            foreach (string eKey in entries.Keys)\n            {\n                if (!field.Contains(eKey))\n                {\n                    continue;\n                }\n\n                foreach (var mapping in mappings)\n                {\n                    var localizeOwner = field[eKey];\n                    var modTrans =\n                        localizeOwner?.GetType().GetProperty(mapping.Key)?.GetValue(localizeOwner) as ModTranslation;\n\n                    modTrans?.Import(mapping.Value.GetValue(entries[eKey]) as BaseEntry, culture);\n                }\n            }\n        }\n    }\n\n    [OperationTiming(OperationTiming.PostContentLoad)]\n    public class BasicImporterPostContentLoad<T> : BasicImporter<T> where T : IFile { }\n\n    [OperationTiming(OperationTiming.BeforeContentLoad)]\n    public class BasicImporterBeforeContentLoad<T> : BasicImporter<T> where T : IFile { }\n}\n"
  },
  {
    "path": "Localizer/Package/Import/CecilLdstrImporter.cs",
    "content": "using System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Reflection;\nusing Harmony;\nusing Localizer.Attributes;\nusing Localizer.DataModel;\nusing Localizer.DataModel.Default;\nusing Mono.Cecil;\nusing Mono.Cecil.Cil;\nusing Ninject;\n\nnamespace Localizer.Package.Import\n{\n    [OperationTiming(OperationTiming.BeforeModCtor)]\n    public class CecilLdstrImporter : LdstrImporterBase\n    {\n        public bool Importing = false;\n        public LdstrFile ImportingFile;\n        public IMod ImportingMod;\n\n        private HarmonyInstance _harmony;\n\n        public CecilLdstrImporter()\n        {\n            _harmony = HarmonyInstance.Create(nameof(CecilLdstrImporter));\n            _harmony.Patch(\"Terraria.ModLoader.Core.AssemblyManager\", \"GetModAssembly\",\n                           postfix: new HarmonyMethod(typeof(CecilLdstrImporter).Method(nameof(PostGetModAssembly))));\n        }\n\n        public static void PostGetModAssembly(ref byte[] __result)\n        {\n            try\n            {\n                var instance = Localizer.Kernel.Get<CecilLdstrImporter>();\n                if (!instance.Importing || !Localizer.Config.ImportLdstr)\n                {\n                    return;\n                }\n\n                using (var ms = new MemoryStream(__result))\n                {\n                    var asmDef = AssemblyDefinition.ReadAssembly(ms);\n                    instance.PatchAssembly(asmDef);\n                    var result = new MemoryStream();\n                    asmDef.Write(result);\n                    __result = result.ToArray();\n                }\n            }\n            catch\n            {\n            }\n        }\n\n        private void PatchAssembly(AssemblyDefinition asm)\n        {\n            var module = asm.MainModule;\n            var entryDict = ImportingFile.LdstrEntries;\n\n            foreach (var entryPair in entryDict)\n            {\n                Utils.SafeWrap(() =>\n                {\n                    if (!HaveTranslation(entryPair.Value))\n                    {\n                        return;\n                    }\n\n                    Utils.LogDebug($\"Finding method: [{entryPair.Key}]\");\n                    var method = Utils.FindMethodByID(module, entryPair.Key);\n                    if (method == null)\n                    {\n                        Utils.LogDebug($\"Cannot find.\");\n                        return;\n                    }\n\n                    var instructions = method.Body?.Instructions;\n                    if (instructions == null || !instructions.Any())\n                    {\n                        return;\n                    }\n\n                    var result = instructions.ToList();\n\n                    foreach (var translation in entryPair.Value.Instructions)\n                    {\n                        ReplaceLdstr(translation.Origin, translation.Translation, result);\n                    }\n\n                    Utils.LogDebug($\"Patched: {entryPair.Key}\");\n                });\n            }\n        }\n\n        protected override void ImportInternal(LdstrFile file, IMod mod, CultureInfo culture)\n        {\n            Importing = true;\n            try\n            {\n                ImportingFile = file;\n                ImportingMod = mod;\n                if ((mod as LoadedModWrapper).wrapped.TryGetTarget(out var loadedMod))\n                {\n                    loadedMod.Invoke(\"set_NeedsReload\", true);\n                    loadedMod.Invoke(\"LoadAssemblies\");\n                }\n            }\n            finally\n            {\n                Importing = false;\n            }\n        }\n\n        private static void ReplaceLdstr(string o, string n, IEnumerable<Instruction> il)\n        {\n            if (string.IsNullOrEmpty(n))\n            {\n                return;\n            }\n\n            foreach (var i in il)\n            {\n                if (i.OpCode == OpCodes.Ldstr && i?.Operand?.ToString() == o)\n                {\n                    i.Operand = n;\n                }\n            }\n        }\n\n        protected override void DisposeUnmanaged()\n        {\n            _harmony.UnpatchAll(nameof(CecilLdstrImporter));\n        }\n    }\n}\n"
  },
  {
    "path": "Localizer/Package/Import/CustomModTranslationImporter.cs",
    "content": "using System.Collections.Generic;\nusing System.Globalization;\nusing System.Reflection;\nusing Localizer.Attributes;\nusing Localizer.DataModel;\nusing Localizer.DataModel.Default;\nusing Localizer.Helpers;\nusing Terraria.ModLoader;\n\nnamespace Localizer.Package.Import\n{\n    [OperationTiming(OperationTiming.PostContentLoad)]\n    public class CustomModTranslationImporter : FileImporter\n    {\n        public override void Import(IFile file, IMod mod, CultureInfo culture)\n        {\n            ImportInternal(file as CustomModTranslationFile, mod, culture);\n        }\n\n        private void ImportInternal(CustomModTranslationFile file, IMod mod, CultureInfo culture)\n        {\n            var entryDict = file.Translations;\n\n            var translations = Utils.GetModByName(mod.Name).ValueOf<IDictionary<string, ModTranslation>>(\"translations\");\n\n\n            if (translations == null)\n            {\n                return;\n            }\n\n            foreach (var pair in entryDict)\n            {\n                if (!translations.ContainsKey(pair.Key))\n                {\n                    continue;\n                }\n\n                var translation = translations[pair.Key];\n                translation?.Import(pair.Value, culture);\n                translations[pair.Key] = translation;\n            }\n        }\n\n        public override IFile Merge(IFile main, IFile addition)\n        {\n            return MergeInternal(main as CustomModTranslationFile, addition as CustomModTranslationFile);\n        }\n\n        internal CustomModTranslationFile MergeInternal(CustomModTranslationFile main, CustomModTranslationFile addition)\n        {\n            var result = new CustomModTranslationFile\n            {\n                Translations = new Dictionary<string, BaseEntry>()\n            };\n\n            foreach (var t in main.Translations)\n            {\n                result.Translations.Add(t.Key, t.Value.Clone() as BaseEntry);\n            }\n\n            foreach (var pair in addition.Translations)\n            {\n                if (result.Translations.ContainsKey(pair.Key))\n                {\n                    result.Translations[pair.Key] = Merge(main.Translations[pair.Key], pair.Value);\n                }\n                else\n                {\n                    result.Translations.Add(pair.Key, pair.Value.Clone() as BaseEntry);\n                }\n            }\n\n            return result;\n        }\n\n        public BaseEntry Merge(BaseEntry main, BaseEntry addition)\n        {\n            var e = main.Clone() as BaseEntry;\n\n            if (string.IsNullOrWhiteSpace(main.Translation))\n            {\n                e.Translation = addition.Translation;\n            }\n\n            return e;\n        }\n\n    }\n}\n"
  },
  {
    "path": "Localizer/Package/Import/FileImporter.cs",
    "content": "using System.Globalization;\nusing Localizer.DataModel;\n\nnamespace Localizer.Package.Import\n{\n    public abstract class FileImporter : Disposable\n    {\n        /// <summary>\n        ///     Import a file into correspond mod.\n        /// </summary>\n        /// <param name=\"file\"></param>\n        /// <param name=\"mod\"></param>\n        /// <param name=\"culture\"></param>\n        public abstract void Import(IFile file, IMod mod, CultureInfo culture);\n\n        /// <summary>\n        ///     Merge an entry into another one.\n        /// </summary>\n        /// <param name=\"main\"></param>\n        /// <param name=\"addition\"></param>\n        /// <returns></returns>\n        public abstract IFile Merge(IFile main, IFile addition);\n\n        public virtual void Reset() { }\n    }\n}\n"
  },
  {
    "path": "Localizer/Package/Import/HarmonyLdstrImporter.cs",
    "content": "using System.Collections.Generic;\nusing System.Globalization;\nusing System.Linq;\nusing System.Reflection;\nusing Harmony;\nusing Localizer.DataModel;\nusing Localizer.DataModel.Default;\n\nnamespace Localizer.Package.Import\n{\n    public sealed class HarmonyLdstrImporter : LdstrImporterBase\n    {\n        private HarmonyInstance harmony;\n\n        private static Dictionary<MethodBase, LdstrEntry> entries;\n\n        public HarmonyLdstrImporter()\n        {\n            harmony = HarmonyInstance.Create(\"LdstrFileImport\");\n        }\n\n        protected override void ImportInternal(LdstrFile file, IMod mod, CultureInfo culture)\n        {\n            entries = new Dictionary<MethodBase, LdstrEntry>();\n\n            var module = mod.Code.ManifestModule;\n            var entryDict = file.LdstrEntries;\n\n            foreach (var entryPair in entryDict)\n            {\n                Utils.SafeWrap(() =>\n                {\n                    if (!HaveTranslation(entryPair.Value))\n                    {\n                        return;\n                    }\n\n                    Utils.LogDebug($\"Finding method: [{entryPair.Key}]\");\n                    var method = Utils.FindMethodByID(module, entryPair.Key);\n                    if (method == null)\n                    {\n                        Utils.LogDebug($\"Cannot find.\");\n                        return;\n                    }\n\n                    entries.Add(method, entryPair.Value);\n\n                    harmony.Patch(method, transpiler: new HarmonyMethod(NoroHelper.MethodInfo(() => Transpile(null, null))));\n\n                    Utils.LogDebug($\"Patched: {entryPair.Key}\");\n                });\n            }\n        }\n\n        public override void Reset()\n        {\n            harmony.UnpatchAll(\"LdstrFileImport\");\n        }\n\n        private static IEnumerable<CodeInstruction> Transpile(IEnumerable<CodeInstruction> instructions, MethodBase original)\n        {\n            if (!entries.ContainsKey(original) || instructions == null || instructions.Count() == 0)\n            {\n                return instructions;\n            }\n\n            var result = instructions.ToList();\n\n            var entry = entries[original];\n\n            foreach (var translation in entry.Instructions)\n            {\n                ReplaceLdstr(translation.Origin, translation.Translation, result);\n            }\n\n            return result;\n        }\n\n        private static void ReplaceLdstr(string o, string n, IEnumerable<CodeInstruction> il)\n        {\n            if (string.IsNullOrEmpty(n))\n            {\n                return;\n            }\n\n            var ins = il.FirstOrDefault(i => i?.operand?.ToString() == o);\n            if (ins != null)\n            {\n                ins.operand = n;\n            }\n        }\n\n        protected override void DisposeUnmanaged()\n        {\n            entries = null;\n            harmony.UnpatchAll(\"LdstrFileImport\");\n        }\n    }\n}\n"
  },
  {
    "path": "Localizer/Package/Import/IPackageImportService.cs",
    "content": "using System;\nusing Localizer.DataModel;\n\nnamespace Localizer.Package.Import\n{\n    public interface IPackageImportService\n    {\n        void RegisterImporter<T>(Type importerType) where T : IFile;\n\n        void UnregisterImporter<T>() where T : IFile;\n\n        /// <summary>\n        ///     Add a package into the internal queue,\n        ///     earlier packages have more priorities.\n        /// </summary>\n        /// <param name=\"package\"></param>\n        void Queue(IPackage package);\n\n        /// <summary>\n        ///     Start the import process.\n        /// </summary>\n        void Import(bool preferEarly);\n\n        /// <summary>\n        ///     Clear internal queue and ready for next work.\n        /// </summary>\n        void Reset();\n\n        /// <summary>\n        /// Clear internal queue.\n        /// </summary>\n        void Clear();\n    }\n}\n"
  },
  {
    "path": "Localizer/Package/Import/LdstrImporterBase.cs",
    "content": "using System.Collections.Generic;\nusing System.Globalization;\nusing Localizer.DataModel;\nusing Localizer.DataModel.Default;\n\nnamespace Localizer.Package.Import\n{\n    public abstract class LdstrImporterBase : FileImporter\n    {\n        internal bool HaveTranslation(LdstrEntry entry)\n        {\n            foreach (var ins in entry.Instructions)\n            {\n                if (!string.IsNullOrEmpty(ins.Translation))\n                {\n                    return true;\n                }\n            }\n\n            return false;\n        }\n\n        public override void Import(IFile file, IMod mod, CultureInfo culture)\n        {\n            ImportInternal(file as LdstrFile, mod, culture);\n        }\n\n        public override IFile Merge(IFile main, IFile addition)\n        {\n            return MergeInternal(main as LdstrFile, addition as LdstrFile);\n        }\n        protected abstract void ImportInternal(LdstrFile file, IMod mod, CultureInfo culture);\n\n        internal LdstrFile MergeInternal(LdstrFile main, LdstrFile addition)\n        {\n            var result = new LdstrFile\n            {\n                LdstrEntries = new Dictionary<string, LdstrEntry>()\n            };\n\n            foreach (var e in main.LdstrEntries)\n            {\n                result.LdstrEntries.Add(e.Key, e.Value.Clone() as LdstrEntry);\n            }\n\n            foreach (var pair in addition.LdstrEntries)\n            {\n                if (result.LdstrEntries.ContainsKey(pair.Key))\n                {\n                    result.LdstrEntries[pair.Key] = Merge(main.LdstrEntries[pair.Key], pair.Value);\n                }\n                else\n                {\n                    result.LdstrEntries.Add(pair.Key, pair.Value);\n                }\n            }\n\n            return result;\n        }\n\n        internal LdstrEntry Merge(LdstrEntry main, LdstrEntry addition)\n        {\n            var result = new LdstrEntry { Instructions = new List<BaseEntry>() };\n\n            foreach (var ins in main.Instructions)\n            {\n                if (!result.Instructions.Exists(i => i.Origin == ins.Origin))\n                {\n                    result.Instructions.Add(ins.Clone() as BaseEntry);\n                }\n            }\n\n            foreach (var ins in addition.Instructions)\n            {\n                if (!result.Instructions.Exists(i => i.Origin == ins.Origin))\n                {\n                    result.Instructions.Add(ins.Clone() as BaseEntry);\n                }\n            }\n\n            return result;\n        }\n    }\n}\n"
  },
  {
    "path": "Localizer/Package/Import/MonoModLdstrImporter.cs",
    "content": "using System.Collections.Generic;\nusing System.Globalization;\nusing System.Linq;\nusing System.Reflection;\nusing Localizer.DataModel;\nusing Localizer.DataModel.Default;\nusing MonoMod.Cil;\nusing MonoMod.RuntimeDetour.HookGen;\n\nnamespace Localizer.Package.Import\n{\n    public class MonoModLdstrImporter : LdstrImporterBase\n    {\n        private Dictionary<MethodBase, ILContext.Manipulator> modifications;\n\n        public MonoModLdstrImporter()\n        {\n            modifications = new Dictionary<MethodBase, ILContext.Manipulator>();\n        }\n\n        protected override void ImportInternal(LdstrFile file, IMod mod, CultureInfo culture)\n        {\n            Terraria.ModLoader.ContentInstance.Register(Utils.GetModByName(mod.Name));\n            var module = mod.Code.ManifestModule;\n\n            var entryDict = file.LdstrEntries;\n\n            foreach (var entryPair in entryDict)\n            {\n                var method = Utils.FindMethodByID(module, entryPair.Key);\n                if (method == null)\n                {\n                    continue;\n                }\n\n                var e = entryPair.Value;\n\n                if (!HaveTranslation(e))\n                {\n                    continue;\n                }\n\n                var modification = new ILContext.Manipulator(il =>\n                {\n                    foreach (var instruction in il.Instrs)\n                    {\n                        var ins = e.Instructions.FirstOrDefault(i => instruction.MatchLdstr(i.Origin));\n                        if (ins == null || string.IsNullOrEmpty(ins.Translation))\n                        {\n                            continue;\n                        }\n\n                        instruction.Operand = ins.Translation;\n\n                        foreach (var label in il.Labels)\n                        {\n                            if (label.Target.MatchLdstr(ins.Origin))\n                            {\n                                label.Target = instruction;\n                            }\n                        }\n                    }\n                });\n\n                if (!modifications.ContainsKey(method))\n                {\n                    HookEndpointManager.Modify(method, modification);\n                    modifications.Add(method, modification);\n                }\n            }\n        }\n\n        public override void Reset()\n        {\n            return;\n        }\n\n        protected override void DisposeUnmanaged()\n        {\n            modifications = null;\n        }\n    }\n}\n"
  },
  {
    "path": "Localizer/Package/Import/PackageImportService.cs",
    "content": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Reflection;\nusing Localizer.Attributes;\nusing Localizer.DataModel;\nusing Localizer.DataModel.Default;\nusing Ninject;\n\nnamespace Localizer.Package.Import\n{\n    public class PackageImportService : IPackageImportService\n    {\n        private readonly List<IPackageGroup> packageGroups = new List<IPackageGroup>();\n\n        private Dictionary<Type, FileImporter> _importers;\n\n        public PackageImportService()\n        {\n            _importers = new Dictionary<Type, FileImporter>();\n        }\n\n        public void RegisterImporter<T>(Type importerType) where T : IFile\n        {\n            if (importerType is null)\n            {\n                throw new ArgumentNullException(nameof(importerType));\n            }\n\n            Localizer.Kernel.Bind(typeof(FileImporter), importerType)\n                     .To(importerType).InSingletonScope();\n\n            var importer = Localizer.Kernel.Get(importerType) as FileImporter;\n            if (importer is null)\n            {\n                Utils.LogError(\"Importer binding failed.\");\n                return;\n            }\n\n            if (_importers.ContainsKey(typeof(T)))\n            {\n                _importers[typeof(T)] = importer;\n            }\n            else\n            {\n                _importers.Add(typeof(T), importer);\n            }\n\n            Utils.LogInfo($\"Importer: [{importer.GetType().FullName}] registered for file type: [{typeof(T).FullName}].\");\n        }\n\n        public void UnregisterImporter<T>() where T : IFile\n        {\n            if (_importers.ContainsKey(typeof(T)))\n            {\n                _importers.Remove(typeof(T));\n                Utils.LogInfo($\"Unregistered importer of type [{typeof(T).FullName}]\");\n            }\n        }\n\n        public void Queue(IPackage package)\n        {\n            if (packageGroups.All(pg => pg.Mod != package.Mod))\n            {\n                packageGroups.Add(new PackageGroup\n                {\n                    Mod = package.Mod,\n                    Packages = new List<IPackage> { package }\n                });\n            }\n            else\n            {\n                packageGroups.FirstOrDefault(pg => pg.Mod == package.Mod)?.Packages.Add(package);\n            }\n\n            Utils.LogDebug($\"Queued [{package.Name}]\");\n        }\n\n        public void Import(bool preferEarly = true)\n        {\n            Utils.LogInfo($\"Begin importing\");\n\n            foreach (var group in packageGroups)\n            {\n                Utils.LogInfo($\"Importing Mod: [{group.Mod.Name}]\");\n                Utils.SafeWrap(() =>\n                {\n                    var merged = Merge(group);\n                    foreach (var f in merged.Files)\n                    {\n                        Utils.SafeWrap(() =>\n                        {\n                            var importer = GetImporter(f);\n                            if (importer is null)\n                            {\n                                return;\n                            }\n\n                            Import(f, group, importer, preferEarly);\n                        });\n                    }\n                });\n            }\n        }\n\n        private void Import(IFile f, IPackageGroup group, FileImporter importer, bool preferEarly)\n        {\n            var importerTiming = importer.GetType().GetCustomAttribute<OperationTimingAttribute>()\n                                                ?.Timing ?? OperationTiming.Any;\n            Utils.LogDebug($\"Trying to Import [{f.GetType()}] using [{importer.GetType()}]\" +\n                           $\"\\n    ImporterTiming: [{importerTiming}]\" +\n                           $\"\\n    State: [{Localizer.State}]\" +\n                           $\"\\n    PreferEarly: [{preferEarly}]\");\n            if (!Localizer.CanDoOperationNow(importer.GetType())\n                || (preferEarly && importerTiming > Localizer.State\n                                && importerTiming == OperationTiming.Any\n                                && Localizer.State != OperationTiming.BeforeModCtor))\n            {\n                return;\n            }\n            importer.Import(f, group.Mod, group.Packages.ToList()[0].Language);\n            Utils.LogDebug($\"Import Complete\");\n        }\n\n        public void Reset()\n        {\n            Utils.LogInfo($\"Resetting importers...\");\n            foreach (var importers in _importers.Values)\n            {\n                importers.Reset();\n            }\n            packageGroups.Clear();\n            Utils.LogInfo($\"Reset completed.\");\n        }\n\n        public void Clear()\n        {\n            Utils.LogInfo($\"Clearing import queue...\");\n            packageGroups.Clear();\n            Utils.LogInfo($\"Cleared.\");\n        }\n\n        private FileImporter GetImporter(IFile file)\n        {\n            if (_importers.TryGetValue(file.GetType(), out var importer))\n            {\n                return importer;\n            }\n\n            Utils.LogWarn($\"No registered importer for file type: [{file.GetType()}]\");\n            return null;\n        }\n\n        internal DataModel.Default.Package Merge(IPackageGroup group)\n        {\n            var result = new DataModel.Default.Package\n            {\n                Mod = group.Mod,\n                ModName = group.Mod.Name,\n                Files = new List<IFile>(),\n                FileList = new List<string>()\n            };\n\n            foreach (var package in group.Packages)\n            {\n                Utils.SafeWrap(() =>\n                {\n                    foreach (var file in package.Files)\n                    {\n                        if (result.Files.All(f => f.GetType() != file.GetType()))\n                        {\n                            result.Files.Add(file);\n                        }\n                        else\n                        {\n                            var main = package.Files.FirstOrDefault(f => f.GetType() == file.GetType());\n                            var importer = GetImporter(file);\n                            if (importer is null)\n                            {\n                                continue;\n                            }\n\n                            var merged = importer.Merge(main, file);\n                            result.Files.Remove(main);\n                            result.Files.Add(merged);\n                        }\n                    }\n                });\n            }\n\n            return result;\n        }\n\n        public void Dispose()\n        {\n            foreach (var importer in _importers.Values)\n            {\n                Utils.SafeWrap(() => importer.Dispose());\n            }\n\n            _importers = null;\n        }\n    }\n}\n"
  },
  {
    "path": "Localizer/Package/Import/RefreshLanguageService.cs",
    "content": "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Reflection;\nusing System.Threading.Tasks;\nusing Harmony;\nusing Terraria.Localization;\nusing Terraria.ModLoader;\n\nnamespace Localizer.Package.Import\n{\n    public sealed class RefreshLanguageService : Disposable\n    {\n        private static RefreshLanguageService _instance;\n\n        private List<WeakReference> items;\n\n        private bool _rebuilding = false;\n        private bool _cleaning = false;\n\n        private HarmonyInstance _harmony;\n\n        private int _cleanUpCounter = 0;\n\n        private bool _firstRun = true;\n\n        public RefreshLanguageService()\n        {\n            _instance = this;\n            items = new List<WeakReference>();\n\n            _harmony = HarmonyInstance.Create(nameof(RefreshLanguageService));\n            _harmony.Patch(typeof(ModItem).GetConstructors()[0], null, NoroHelper.HarmonyMethod(() => OnModItemCtor(null)));\n        }\n\n        private static void OnModItemCtor(ModItem __instance)\n        {\n            if (!Localizer.Config.RebuildTooltips)\n            {\n                return;\n            }\n\n            if (Localizer.Config.RebuildTooltipsOnce && !_instance._firstRun)\n            {\n                return;\n            }\n\n            if (!_instance._rebuilding && !_instance._cleaning)\n            {\n                _instance.items.Add(new WeakReference(__instance));\n                _instance._cleanUpCounter++;\n\n                if (_instance._cleanUpCounter > 20000 && !_instance._firstRun)\n                {\n                    Task.Run(() => _instance.CleanUpItems());\n\n                    _instance._cleanUpCounter = 0;\n                }\n            }\n        }\n\n        public void Refresh()\n        {\n            Utils.SafeWrap(() =>\n            {\n                if (Localizer.State != OperationTiming.BeforeModCtor)\n                {\n                    ModContent.RefreshModLanguage(LanguageManager.Instance.ActiveCulture);\n                }\n\n                if (Localizer.Config.RebuildTooltips && Localizer.State == OperationTiming.PostContentLoad)\n                {\n                    _rebuilding = true;\n                    CleanUpItems();\n                    var stopWatch = new Stopwatch();\n                    Utils.LogInfo($\"Rebuilding tooltips, count: {items.Count}\");\n                    stopWatch.Start();\n                    foreach (var i in items)\n                    {\n                        (i.Target as ModItem)?.item.RebuildTooltip();\n                    }\n\n                    stopWatch.Stop();\n                    Utils.LogInfo(\n                        $\"Rebuilding completed. count: {items.Count}, take {stopWatch.Elapsed.TotalSeconds} seconds\");\n                    _rebuilding = false;\n                }\n            });\n        }\n\n        private void CleanUpItems()\n        {\n            var deads = new List<WeakReference>();\n            _cleaning = true;\n            var stopWatch = new Stopwatch();\n            Utils.LogInfo($\"Cleaning item caches, count: {items.Count}\");\n            stopWatch.Start();\n            lock (items)\n            {\n                foreach (var wr in items)\n                {\n                    if (!wr.IsAlive)\n                    {\n                        deads.Add(wr);\n                    }\n                }\n\n                foreach (var d in deads)\n                {\n                    items.Remove(d);\n                }\n            }\n            stopWatch.Stop();\n            Utils.LogInfo($\"Item caches cleaned. count: {items.Count}, take {stopWatch.Elapsed.TotalSeconds} seconds\");\n            if (_firstRun)\n            {\n                _firstRun = false;\n            }\n\n            _cleaning = false;\n        }\n\n        protected override void DisposeUnmanaged()\n        {\n            _instance = null;\n            _harmony.UnpatchAll(nameof(RefreshLanguageService));\n        }\n    }\n}\n"
  },
  {
    "path": "Localizer/Package/Load/IFileLoadService.cs",
    "content": "using System.IO;\nusing Localizer.DataModel;\n\nnamespace Localizer.Package.Load\n{\n    public interface IFileLoadService\n    {\n        /// <summary>\n        ///     Load a file from stream.\n        /// </summary>\n        /// <param name=\"stream\"></param>\n        /// <param name=\"typeName\"></param>\n        /// <returns></returns>\n        IFile Load(Stream stream, string typeName);\n    }\n}\n"
  },
  {
    "path": "Localizer/Package/Load/IPackageLoadService.cs",
    "content": "using Localizer.DataModel;\n\nnamespace Localizer.Package.Load\n{\n    public interface IPackageLoadService<T> where T : IPackage\n    {\n        /// <summary>\n        ///     Load a package.\n        /// </summary>\n        /// <param name=\"path\"></param>\n        /// <param name=\"fileLoadService\"></param>\n        /// <returns></returns>\n        IPackage Load(string path, IFileLoadService fileLoadService);\n    }\n}\n"
  },
  {
    "path": "Localizer/Package/Load/JsonFileLoad.cs",
    "content": "using System;\nusing System.Collections.Generic;\nusing System.IO;\nusing Localizer.DataModel;\nusing Localizer.DataModel.Default;\n\nnamespace Localizer.Package.Load\n{\n    public class JsonFileLoad : IFileLoadService\n    {\n        private static Dictionary<string, Type> fileTypes = new Dictionary<string, Type>\n        {\n            {typeof(BasicItemFile).Name, typeof(BasicItemFile)},\n            {typeof(BasicBuffFile).Name, typeof(BasicBuffFile)},\n            {typeof(CustomModTranslationFile).Name, typeof(CustomModTranslationFile)},\n            {typeof(BasicNPCFile).Name, typeof(BasicNPCFile)},\n            {typeof(BasicProjectileFile).Name, typeof(BasicProjectileFile)},\n            {typeof(BasicPrefixFile).Name, typeof(BasicPrefixFile)},\n            {typeof(LdstrFile).Name, typeof(LdstrFile)}\n        };\n\n        public IFile Load(Stream stream, string typeName)\n        {\n            if (!fileTypes.ContainsKey(typeName))\n            {\n                Localizer.Log.Error(string.Format(\"Not supported file type: {0}\", typeName));\n                return null;\n            }\n\n            var type = fileTypes[typeName];\n\n            var file = Utils.ReadFileAndDeserializeJson(type, stream) as IFile;\n\n            if (file == null)\n            {\n                Localizer.Log.Error(string.Format(\"File deserialization failed!, FileType: {0}\", type.FullName));\n            }\n\n            return file;\n        }\n\n        public void RegisterType(string typeName, Type type)\n        {\n            if (fileTypes == null)\n            {\n                fileTypes = new Dictionary<string, Type>();\n            }\n\n            if (fileTypes.ContainsKey(typeName))\n            {\n                fileTypes[typeName] = type;\n            }\n            else\n            {\n                fileTypes.Add(typeName, type);\n            }\n        }\n\n        public void Dispose()\n        {\n        }\n    }\n}\n"
  },
  {
    "path": "Localizer/Package/Load/PackedPackageLoad.cs",
    "content": "using System.IO;\nusing System.IO.Compression;\nusing Localizer.DataModel;\n\nnamespace Localizer.Package.Load\n{\n    public sealed class PackedPackageLoad<T> : IPackageLoadService<T> where T : IPackage\n    {\n        private readonly string _packageMainFileName = \"Package.json\";\n\n        public IPackage Load(string path, IFileLoadService fileLoadService)\n        {\n            Utils.LogDebug($\"Loading package from {path}\");\n\n            if (!System.IO.File.Exists(path))\n            {\n                Utils.LogError(\"Package file doesn't exist!\");\n                return null;\n            }\n\n            using (var zipFileToOpen = new FileStream(path, FileMode.Open))\n            {\n                using (var archive = new ZipArchive(zipFileToOpen, ZipArchiveMode.Read))\n                {\n                    var packageStream = archive.GetEntry(_packageMainFileName)?.Open();\n\n                    IPackage package = Utils.ReadFileAndDeserializeJson<T>(packageStream);\n                    if (package == null)\n                    {\n                        Utils.LogError(\"Package main file deserialization failed!\");\n                        return null;\n                    }\n\n                    var mod = Localizer.GetWrappedMod(package.ModName);\n                    if (mod == null)\n                    {\n                        Utils.LogError($\"Package Mod {package.ModName} not loaded!\");\n                        return null;\n                    }\n\n                    package.Mod = mod;\n\n                    foreach (var fileTypeName in package.FileList)\n                    {\n                        Utils.LogDebug($\"Loading file [{fileTypeName}]\");\n\n                        var fs = archive.GetEntry($\"{fileTypeName}.json\")?.Open();\n                        var file = fileLoadService.Load(fs, fileTypeName);\n\n                        package.AddFile(file);\n                    }\n\n                    Utils.LogDebug($\"Package [{package.Name} loaded.]\");\n\n                    return package;\n                }\n            }\n        }\n\n        public void Dispose()\n        {\n        }\n    }\n}\n"
  },
  {
    "path": "Localizer/Package/Load/SourcePackageLoad.cs",
    "content": "using System.IO;\nusing Localizer.DataModel;\nusing File = System.IO.File;\n\nnamespace Localizer.Package.Load\n{\n    public sealed class SourcePackageLoad<T> : IPackageLoadService<T> where T : IPackage\n    {\n        private readonly string _packageMainFileName = \"Package.json\";\n\n        public IPackage Load(string path, IFileLoadService fileLoadService)\n        {\n            Utils.LogDebug($\"Loading package from {path}\");\n\n            if (!Directory.Exists(path))\n            {\n                Utils.LogError(\"Package directory doesn't exist!\");\n                return null;\n            }\n\n            var packDir = new DirectoryInfo(path);\n            var packageFilePath = Path.Combine(packDir.FullName, _packageMainFileName);\n            if (!File.Exists(packageFilePath))\n            {\n                Utils.LogError(\"Package main file doesn't exist!\");\n                return null;\n            }\n\n            IPackage package = Utils.ReadFileAndDeserializeJson<T>(packageFilePath);\n            if (package == null)\n            {\n                Utils.LogError(\"Package main file deserialization failed!\");\n                return null;\n            }\n\n            var mod = Localizer.GetWrappedMod(package.ModName);\n            if (mod == null)\n            {\n                Utils.LogError($\"Package Mod {package.ModName} not loaded!\");\n                return null;\n            }\n\n            package.Mod = mod;\n\n            foreach (var fileTypeName in package.FileList)\n            {\n                Utils.LogDebug($\"Loading file [{fileTypeName}]\");\n\n                var filePath = Path.Combine(packDir.FullName, fileTypeName + \".json\");\n                using (var fs = new FileStream(filePath, FileMode.Open))\n                {\n                    var file = fileLoadService.Load(fs, fileTypeName);\n\n                    package.AddFile(file);\n                }\n            }\n\n            Utils.LogDebug($\"Package [{package.Name} loaded.]\");\n\n            return package;\n        }\n\n        public void Dispose()\n        {\n        }\n    }\n}\n"
  },
  {
    "path": "Localizer/Package/Pack/IPackagePackService.cs",
    "content": "namespace Localizer.Package.Pack\n{\n    public interface IPackagePackService\n    {\n        /// <summary>\n        ///     Pack up a package.\n        /// </summary>\n        /// <param name=\"path\">Path of the package main file.</param>\n        void Pack(string path);\n    }\n}\n"
  },
  {
    "path": "Localizer/Package/Pack/ZipPackagePackService.cs",
    "content": "using System.IO;\nusing System.IO.Compression;\nusing Localizer.DataModel;\n\nnamespace Localizer.Package.Pack\n{\n    public class ZipPackagePackService<T> : IPackagePackService where T : IPackage\n    {\n        private readonly string _packageMainFileName = \"Package.json\";\n\n        public void Pack(string path)\n        {\n            Utils.LogDebug($\"Packing package from {path}\");\n\n            if (!System.IO.File.Exists(path))\n            {\n                Utils.LogError(\"Cannot find the package file!\");\n                return;\n            }\n\n            var packDir = new FileInfo(path).Directory;\n\n            var package = Utils.ReadFileAndDeserializeJson<T>(path);\n            using (var zipFileToOpen = new FileStream($\"{packDir.FullName}/{package.Name}.locpack\", FileMode.Create))\n            {\n                using (var archive = new ZipArchive(zipFileToOpen, ZipArchiveMode.Create))\n                {\n                    Utils.WriteZipArchiveEntry(archive, path, _packageMainFileName);\n\n                    foreach (var filename in package.FileList)\n                    {\n                        Utils.LogDebug($\"Writing {filename}\");\n\n                        var filePath = Path.Combine(packDir.FullName, filename + \".json\");\n\n                        if (!System.IO.File.Exists(filePath))\n                        {\n                            Utils.LogError($\"Cannot find file: {filePath}!\");\n                            continue;\n                        }\n\n                        Utils.WriteZipArchiveEntry(archive, filePath, filename + \".json\");\n                    }\n                }\n            }\n\n            Utils.LogDebug(\"Packed\");\n        }\n\n        public void Dispose()\n        {\n        }\n    }\n}\n"
  },
  {
    "path": "Localizer/Package/PackageManageService.cs",
    "content": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing Localizer.DataModel;\nusing Localizer.DataModel.Default;\n\nnamespace Localizer.Package\n{\n    public class PackageManageService : IPackageManageService\n    {\n        private readonly string stateSavePath = Localizer.SavePath + \"PackageStates.json\";\n\n        public ICollection<IPackageGroup> PackageGroups { get; set; }\n\n        private List<PackageGroupState> oldPackageGroupStates = new List<PackageGroupState>();\n\n        /// <summary>\n        ///     Add a package into PackageGroups.\n        /// </summary>\n        /// <param name=\"package\"></param>\n        public void AddPackage(IPackage package)\n        {\n            if (package == null)\n            {\n                return;\n            }\n\n            if (PackageGroups.All(pg => pg.Mod.Name != package.Mod.Name))\n            {\n                PackageGroups.Add(new PackageGroup\n                {\n                    Mod = package.Mod,\n                    Packages = new List<IPackage> { package }\n                });\n            }\n            else\n            {\n                PackageGroups.FirstOrDefault(\n                    pg => pg.Mod.Name == package.Mod.Name &&\n                          pg.Packages.All(p => p.Name != package.Name))?.Packages.Add(package);\n            }\n        }\n\n        public void RemovePackage(IPackage package)\n        {\n            throw new NotImplementedException();\n        }\n\n        public void LoadState()\n        {\n            if (!System.IO.File.Exists(stateSavePath))\n            {\n                return;\n            }\n\n            oldPackageGroupStates = Utils.ReadFileAndDeserializeJson<List<PackageGroupState>>(stateSavePath) ??\n                         new List<PackageGroupState>();\n\n            foreach (var state in oldPackageGroupStates)\n            {\n                var packageGroup = PackageGroups.FirstOrDefault(pg => pg.Mod.Name == state.ModName);\n                if (packageGroup == null)\n                {\n                    continue;\n                }\n\n                foreach (var p in packageGroup.Packages)\n                {\n                    if (state.Packages.Contains(p.Name))\n                    {\n                        p.Enabled = (bool)state.Packages[p.Name];\n                    }\n                }\n            }\n        }\n\n        public void SaveState()\n        {\n            foreach (var pg in PackageGroups)\n            {\n                var state = oldPackageGroupStates.FirstOrDefault(s => s.ModName == pg.Mod.Name);\n                if (state != null)\n                {\n                    oldPackageGroupStates.Remove(state);\n                }\n\n                oldPackageGroupStates.Add(new PackageGroupState(pg));\n            }\n\n            Utils.SerializeJsonAndCreateFile(oldPackageGroupStates, stateSavePath);\n        }\n\n        public void Dispose()\n        {\n        }\n    }\n}\n"
  },
  {
    "path": "Localizer/Package/Save/IFileSaveService.cs",
    "content": "using Localizer.DataModel;\n\nnamespace Localizer.Package.Save\n{\n    public interface IFileSaveService\n    {\n        /// <summary>\n        ///     Save a file.\n        /// </summary>\n        /// <param name=\"file\"></param>\n        /// <param name=\"path\"></param>\n        void Save(IFile file, string path);\n    }\n}\n"
  },
  {
    "path": "Localizer/Package/Save/IPackageSaveService.cs",
    "content": "using Localizer.DataModel;\n\nnamespace Localizer.Package.Save\n{\n    public interface IPackageSaveService\n    {\n        /// <summary>\n        ///     Save a package to filesystem.\n        /// </summary>\n        /// <param name=\"package\"></param>\n        /// <param name=\"path\"></param>\n        /// <param name=\"fileSaveDisposable\"></param>\n        void Save(IPackage package, string path, IFileSaveService fileSaveDisposable);\n    }\n}\n"
  },
  {
    "path": "Localizer/Package/Save/JsonFileSaveService.cs",
    "content": "using Localizer.DataModel;\n\nnamespace Localizer.Package.Save\n{\n    public class JsonFileSaveService : IFileSaveService\n    {\n        public void Save(IFile file, string path)\n        {\n            Utils.SerializeJsonAndCreateFile(file, path);\n        }\n\n        public void Dispose()\n        {\n        }\n    }\n}\n"
  },
  {
    "path": "Localizer/Package/Save/PackageSaveService.cs",
    "content": "using System.IO;\nusing Localizer.DataModel;\n\nnamespace Localizer.Package.Save\n{\n    public class PackageSave : IPackageSaveService\n    {\n        public void Save(IPackage package, string path, IFileSaveService fileSaveDisposable)\n        {\n            Utils.SerializeJsonAndCreateFile(package, Path.Combine(path, \"Package.json\"));\n\n            foreach (var file in package.Files)\n            {\n                fileSaveDisposable.Save(file, Path.Combine(path, file.GetType().Name + \".json\"));\n            }\n        }\n\n        public void Dispose()\n        {\n        }\n    }\n}\n"
  },
  {
    "path": "Localizer/Package/Update/BasicFileUpdater.cs",
    "content": "using System.Collections;\nusing System.Collections.Generic;\nusing Localizer.DataModel;\nusing Localizer.DataModel.Default;\nusing Localizer.Helpers;\n\nnamespace Localizer.Package.Update\n{\n    public sealed class BasicFileUpdater<T> : FileUpdater where T : IFile\n    {\n        public override void Update(IFile oldFile, IFile newFile, IUpdateLogger logger)\n        {\n            CheckArgs(oldFile, newFile, logger);\n            UpdateInternal((T)oldFile, (T)newFile, logger);\n        }\n\n        public void UpdateInternal(T oldFile, T newFile, IUpdateLogger logger)\n        {\n            if (oldFile.GetType() != typeof(T) || newFile.GetType() != typeof(T))\n            {\n                return;\n            }\n\n            foreach (var prop in typeof(T).ModTranslationOwnerField())\n            {\n                var oldEntries = (IDictionary)prop.GetValue(oldFile);\n                var newEntries = (IDictionary)prop.GetValue(newFile);\n\n                foreach (string newEntryKey in newEntries.Keys)\n                {\n                    if (oldEntries.Contains(newEntryKey))\n                    {\n                        UpdateEntry(newEntryKey, oldFile.GetValue(newEntryKey), newFile.GetValue(newEntryKey), logger);\n                    }\n                    else\n                    {\n                        logger.Add($\"[{newEntryKey}]\");\n                        var entry = (newEntries[newEntryKey] as IEntry).Clone();\n                        oldEntries.Add(newEntryKey, entry);\n                    }\n                }\n\n                var removed = new List<string>();\n                foreach (string k in oldEntries.Keys)\n                {\n                    if (!newEntries.Contains(k))\n                    {\n                        removed.Add(k);\n                    }\n                }\n\n                foreach (var r in removed)\n                {\n                    logger.Remove($\"[{r}]\");\n                }\n\n                prop.SetValue(oldFile, oldEntries);\n            }\n        }\n\n        internal void UpdateEntry(string key, IEntry oldEntry, IEntry newEntry, IUpdateLogger logger)\n        {\n            foreach (var prop in oldEntry.GetType().ModTranslationProp())\n            {\n                var o = prop.GetValue(oldEntry) as BaseEntry;\n                var n = prop.GetValue(newEntry) as BaseEntry;\n\n                if (o.Origin != n.Origin)\n                {\n                    logger.Change($\"{key}'s {prop.Name}\\r\\n[Old: \\\"{o.Origin}\\\"]\\r\\n => \\r\\n[New: \\\"{n.Origin}\\\"]\\r\\n\");\n\n                    o.Origin = n.Origin;\n                    o.Translation = n.Translation;\n                }\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "Localizer/Package/Update/CustomModTranslationUpdater.cs",
    "content": "using System.Linq;\nusing Localizer.DataModel;\nusing Localizer.DataModel.Default;\n\nnamespace Localizer.Package.Update\n{\n    public class CustomModTranslationUpdater : FileUpdater\n    {\n        public override void Update(IFile oldFile, IFile newFile, IUpdateLogger logger)\n        {\n            CheckArgs(oldFile, newFile, logger);\n            UpdateInternal(oldFile as CustomModTranslationFile, newFile as CustomModTranslationFile, logger);\n        }\n\n        public void UpdateInternal(CustomModTranslationFile oldFile, CustomModTranslationFile newFile, IUpdateLogger logger)\n        {\n            var oldEntries = oldFile.Translations;\n            var newEntries = newFile.Translations;\n\n            foreach (var newEntryKey in newEntries.Keys)\n            {\n                if (oldEntries.Keys.Contains(newEntryKey))\n                {\n                    var o = oldEntries[newEntryKey];\n                    var n = newEntries[newEntryKey];\n                    if (o.Origin != n.Origin)\n                    {\n                        logger.Change($\"{newEntryKey}\\r\\n[Old: \\\"{o.Origin}\\\"]\\r\\n => \\r\\n[New: \\\"{n.Origin}\\\"]\\r\\n\");\n\n                        o.Origin = n.Origin;\n                        o.Translation = n.Translation;\n                    }\n                }\n                else\n                {\n                    logger.Add($\"[{newEntryKey}]\");\n                    var entry = newEntries[newEntryKey];\n                    oldEntries.Add(newEntryKey, entry);\n                }\n            }\n\n            var removed = oldEntries.Keys.Where(k => !newEntries.ContainsKey(k));\n\n            foreach (var r in removed)\n            {\n                logger.Remove($\"[{r}]\");\n            }\n        }\n\n        public void Dispose()\n        {\n        }\n    }\n}\n"
  },
  {
    "path": "Localizer/Package/Update/FileUpdater.cs",
    "content": "using System;\nusing Localizer.DataModel;\n\nnamespace Localizer.Package.Update\n{\n    public abstract class FileUpdater\n    {\n        /// <summary>\n        ///     Compare two packages and merge differences into old one.\n        ///     Generate reports with logger.\n        /// </summary>\n        /// <param name=\"oldFile\"></param>\n        /// <param name=\"newFile\"></param>\n        /// <param name=\"logger\"></param>\n        public abstract void Update(IFile oldFile, IFile newFile, IUpdateLogger logger);\n\n        internal void CheckArgs(IFile oldFile, IFile newFile, IUpdateLogger logger)\n        {\n            if (oldFile is null)\n            {\n                throw new ArgumentNullException(nameof(oldFile));\n            }\n\n            if (newFile is null)\n            {\n                throw new ArgumentNullException(nameof(newFile));\n            }\n\n            if (logger is null)\n            {\n                throw new ArgumentNullException(nameof(logger));\n            }\n\n            if (oldFile.GetType() != newFile.GetType())\n            {\n                throw new Exception($\"Different file type: [{oldFile.GetType().FullName}] and [{newFile.GetType().FullName}]\");\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "Localizer/Package/Update/IPackageUpdateService.cs",
    "content": "using Localizer.DataModel;\n\nnamespace Localizer.Package.Update\n{\n    public interface IPackageUpdateService\n    {\n        void RegisterUpdater<T>(FileUpdater updater) where T : IFile;\n\n        void UnregisterUpdater<T>() where T : IFile;\n\n        /// <summary>\n        ///     Compare two packages and merge differences into old one.\n        ///     Generate reports with logger.\n        /// </summary>\n        /// <param name=\"oldPackage\"></param>\n        /// <param name=\"newPackage\"></param>\n        /// <param name=\"logger\"></param>\n        void Update(IPackage oldPackage, IPackage newPackage, IUpdateLogger logger);\n    }\n}\n"
  },
  {
    "path": "Localizer/Package/Update/IUpdateLogger.cs",
    "content": "namespace Localizer.Package.Update\n{\n    public interface IUpdateLogger\n    {\n        /// <summary>\n        ///     Initialization works of the logger.\n        /// </summary>\n        /// <param name=\"name\"></param>\n        void Init(string name);\n\n        /// <summary>\n        ///     Used when something has been added.\n        /// </summary>\n        /// <param name=\"content\"></param>\n        void Add(object content);\n\n        /// <summary>\n        ///     Used when something has been removed.\n        /// </summary>\n        /// <param name=\"content\"></param>\n        void Remove(object content);\n\n        /// <summary>\n        ///     Used when something has been changed.\n        /// </summary>\n        /// <param name=\"content\"></param>\n        void Change(object content);\n    }\n}\n"
  },
  {
    "path": "Localizer/Package/Update/LdstrFileUpdater.cs",
    "content": "using System.Linq;\nusing Localizer.DataModel;\nusing Localizer.DataModel.Default;\n\nnamespace Localizer.Package.Update\n{\n    public class LdstrFileUpdater : FileUpdater\n    {\n        public override void Update(IFile oldFile, IFile newFile, IUpdateLogger logger)\n        {\n            CheckArgs(oldFile, newFile, logger);\n            UpdateInternal(oldFile as LdstrFile, newFile as LdstrFile, logger);\n        }\n\n        public void UpdateInternal(LdstrFile oldFile, LdstrFile newFile, IUpdateLogger logger)\n        {\n            var oldEntries = oldFile.LdstrEntries;\n            var newEntries = newFile.LdstrEntries;\n\n            foreach (var newEntryKey in newEntries.Keys)\n            {\n                if (oldEntries.Keys.Contains(newEntryKey))\n                {\n                    var o = oldEntries[newEntryKey];\n                    var n = newEntries[newEntryKey];\n                    foreach (var newIns in n.Instructions)\n                    {\n                        if (o.Instructions.Exists(oi => oi.Origin == newIns.Origin))\n                        {\n                            continue;\n                        }\n\n                        o.Instructions.Add(newIns);\n                        logger.Change($\"New instruction of {newEntryKey}: [{newIns}]\");\n                    }\n                }\n                else\n                {\n                    logger.Add($\"[{newEntryKey}]\");\n                    var entry = newEntries[newEntryKey];\n                    oldEntries.Add(newEntryKey, entry);\n                }\n            }\n\n            var removed = oldEntries.Keys.Where(k => !newEntries.ContainsKey(k));\n            foreach (var r in removed)\n            {\n                logger.Remove($\"[{r}]\");\n            }\n        }\n\n        public void Dispose()\n        {\n        }\n    }\n}\n"
  },
  {
    "path": "Localizer/Package/Update/PackageUpdateService.cs",
    "content": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing Localizer.DataModel;\n\nnamespace Localizer.Package.Update\n{\n    public sealed class PackageUpdateService : IPackageUpdateService\n    {\n        private Dictionary<Type, FileUpdater> _updaters;\n\n        public PackageUpdateService()\n        {\n            _updaters = new Dictionary<Type, FileUpdater>();\n        }\n\n        public void RegisterUpdater<T>(FileUpdater updater) where T : IFile\n        {\n            if (updater is null)\n            {\n                throw new ArgumentNullException(nameof(updater));\n            }\n\n            if (_updaters.ContainsKey(typeof(T)))\n            {\n                _updaters[typeof(T)] = updater;\n            }\n            else\n            {\n                _updaters.Add(typeof(T), updater);\n            }\n\n            Utils.LogInfo($\"Updater: [{updater.GetType().FullName}] registered for file type: [{typeof(T).FullName}].\");\n        }\n\n        public void UnregisterUpdater<T>() where T : IFile\n        {\n            if (_updaters.ContainsKey(typeof(T)))\n            {\n                _updaters.Remove(typeof(T));\n                Utils.LogInfo($\"Unregistered updater of type [{typeof(T).FullName}]\");\n            }\n        }\n\n        public void Update(IPackage oldPackage, IPackage newPackage, IUpdateLogger logger)\n        {\n            Utils.LogDebug($\"Updating package [{oldPackage.Name}]\");\n\n            foreach (var oldFile in oldPackage.Files)\n            {\n                var updater = GetUpdater(oldFile);\n                if (updater is null)\n                {\n                    continue;\n                }\n\n                Utils.SafeWrap(() =>\n                {\n                    updater.Update(oldFile, newPackage.Files.FirstOrDefault(f => f.GetType() == oldFile.GetType()),\n                                   logger);\n                });\n            }\n\n            foreach (var file in newPackage.Files)\n            {\n                if (oldPackage.Files.All(f => f.GetType() != file.GetType()))\n                {\n                    oldPackage.AddFile(file);\n                }\n            }\n\n            Utils.LogDebug($\"Package [{oldPackage.Name}] updated.\");\n        }\n\n        private FileUpdater GetUpdater<T>(T file) where T : IFile\n        {\n            if (_updaters.TryGetValue(file.GetType(), out var updater))\n            {\n                return updater;\n            }\n\n            Utils.LogWarn($\"No registered importer for file type: [{file.GetType()}]\");\n            return null;\n        }\n    }\n}\n"
  },
  {
    "path": "Localizer/Package/Update/PlainUpdateLogger.cs",
    "content": "using System.IO;\n\nnamespace Localizer.Package.Update\n{\n    public class PlainUpdateLogger : IUpdateLogger\n    {\n        private static readonly string logDirPath = Path.Combine(Localizer.SavePath, \"UpdateLogs\");\n\n        private string path;\n\n        public void Init(string name)\n        {\n            Utils.EnsureDir(logDirPath);\n            path = Path.Combine(logDirPath, name + \".txt\");\n        }\n\n        public void Add(object content)\n        {\n            System.IO.File.AppendAllText(path, $\"[Content Added]: {content} \\r\\n\");\n        }\n\n        public void Remove(object content)\n        {\n            System.IO.File.AppendAllText(path, $\"[Content Removed]: {content} \\r\\n\");\n        }\n\n        public void Change(object content)\n        {\n            System.IO.File.AppendAllText(path, $\"[Content Changed]: {content} \\r\\n\");\n        }\n\n        public void Dispose()\n        {\n        }\n    }\n}\n"
  },
  {
    "path": "Localizer/Properties/AssemblyInfo.cs",
    "content": "using System.Runtime.CompilerServices;\n\n[assembly: InternalsVisibleTo(\"LocalizerTest\")]\n"
  },
  {
    "path": "Localizer/UIs/Components/BasicListBox.cs",
    "content": "using Squid;\n\nnamespace Localizer.UIs.Components\n{\n    public class BasicListBox : ListBox\n    {\n        public BasicListBox()\n        {\n            base.Dock = DockStyle.Fill;\n            base.Scrollbar.Size = new Point(14, 10);\n            base.Scrollbar.Slider.Style = \"vscrollTrack\";\n            base.Scrollbar.Slider.Button.Style = \"vscrollButton\";\n            base.Scrollbar.ButtonUp.Style = \"vscrollUp\";\n            base.Scrollbar.ButtonUp.Size = new Point(10, 20);\n            base.Scrollbar.ButtonDown.Style = \"vscrollUp\";\n            base.Scrollbar.ButtonDown.Size = new Point(10, 20);\n        }\n    }\n}\n"
  },
  {
    "path": "Localizer/UIs/Components/BasicWindow.cs",
    "content": "using Squid;\n\nnamespace Localizer.UIs.Components\n{\n    public class BasicWindow : Window\n    {\n        public TitleBar Titlebar { get; private set; }\n\n        public BasicWindow()\n        {\n            AllowDragOut = true;\n            Padding = new Margin(4);\n            Titlebar = new TitleBar\n            {\n                Dock = DockStyle.Top,\n                Size = new Point(122, 35)\n            };\n            Titlebar.MouseDown += (sender, args) => StartDrag();\n            Titlebar.MouseUp += (sender, args) => StopDrag();\n            Titlebar.Cursor = CursorNames.Move;\n            Titlebar.Style = \"frame\";\n            Titlebar.Margin = new Margin(-4, -4, -4, -1);\n            Titlebar.Button.MouseClick += Button_OnMouseClick;\n            Titlebar.TextAlign = Alignment.MiddleLeft;\n            Titlebar.BBCodeEnabled = true;\n            AllowDragOut = false;\n\n            Controls.Add(Titlebar);\n        }\n\n        private void Button_OnMouseClick(Control sender, MouseEventArgs args)\n        {\n        }\n    }\n}\n"
  },
  {
    "path": "Localizer/UIs/Components/LabelListBoxItem.cs",
    "content": "using Squid;\n\nnamespace Localizer.UIs.Components\n{\n    public class LabelListBoxItem : ListBoxItem\n    {\n        public Label Label\n        {\n            get;\n            set;\n        }\n\n        public new string Text => Label.Text;\n\n        public LabelListBoxItem(string text)\n        {\n            base.Margin = new Margin(0, 5, 0, 5);\n            Label = new Label\n            {\n                Text = text,\n                Dock = DockStyle.Fill,\n                Style = \"label\"\n            };\n        }\n    }\n}\n"
  },
  {
    "path": "Localizer/UIs/Components/TitleBar.cs",
    "content": "using Squid;\n\nnamespace Localizer.UIs.Components\n{\n    public class TitleBar : Label\n    {\n        public Button Button { get; private set; }\n\n        public TitleBar()\n        {\n            Button = new Button\n            {\n                Size = new Point(30, 30),\n                Style = \"button\",\n                Text = \"X\",\n                TextAlign = Alignment.MiddleCenter,\n                Tooltip = \"Close Window\",\n                Dock = DockStyle.Right,\n                Margin = new Margin(0, 8, 8, 8)\n            };\n            Elements.Add(Button);\n        }\n    }\n}\n"
  },
  {
    "path": "Localizer/UIs/MainWindow.cs",
    "content": "using System;\nusing System.Collections.Generic;\nusing System.Collections.ObjectModel;\nusing System.Diagnostics;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Threading.Tasks;\nusing Localizer.DataModel;\nusing Localizer.Helpers;\nusing Localizer.Network;\nusing Localizer.Package;\nusing Localizer.Package.Export;\nusing Localizer.Package.Load;\nusing Localizer.Package.Save;\nusing Localizer.Package.Update;\nusing Localizer.UIs.Components;\nusing Ninject;\nusing Squid;\nusing Terraria.Localization;\nusing static Localizer.Lang;\n\nnamespace Localizer.UIs\n{\n    public class MainWindow : BasicWindow\n    {\n        private Panel _menuBar;\n\n        private SplitContainer _split;\n\n        private BasicListBox _modList = new BasicListBox();\n\n        private BasicListBox _pkgList = new BasicListBox\n        {\n            MaxSelected = 0,\n            AllowDrop = true\n        };\n\n        private IPackageManageService pkgManager;\n\n        private IFileLoadService fileLoadService;\n\n        private IFileSaveService fileSaveService;\n\n        private IPackageExportService packageExportService;\n\n        private IPackageSaveService packageSaveService;\n\n        private IPackageUpdateService packageUpdateService;\n\n        private IPackageLoadService<DataModel.Default.Package> packedPackageLoadServiceService;\n\n        private IPackageLoadService<DataModel.Default.Package> sourcePackageLoadServiceService;\n\n        private IPackageBrowserService packageBrowserService;\n\n        private IDownloadManagerService downloadManagerService;\n\n        private List<IPackage> onlinePackages = new List<IPackage>();\n\n        private bool loading = false;\n\n        public MainWindow()\n        {\n            Button AddButton(string text, string tooltip, MouseEvent action)\n            {\n                var button = new Button\n                {\n                    Text = text,\n                    Tooltip = tooltip,\n                    Dock = DockStyle.Left\n                };\n                button.MouseClick += action;\n                _menuBar.Content.Controls.Add(button);\n                return button;\n            }\n\n            loading = true;\n            pkgManager = Localizer.Kernel.Get<IPackageManageService>();\n            sourcePackageLoadServiceService = Localizer.Kernel.Get<SourcePackageLoad<DataModel.Default.Package>>();\n            packedPackageLoadServiceService = Localizer.Kernel.Get<PackedPackageLoad<DataModel.Default.Package>>();\n            packageExportService = Localizer.Kernel.Get<IPackageExportService>();\n            packageSaveService = Localizer.Kernel.Get<IPackageSaveService>();\n            packageUpdateService = Localizer.Kernel.Get<IPackageUpdateService>();\n            fileLoadService = Localizer.Kernel.Get<IFileLoadService>();\n            fileSaveService = Localizer.Kernel.Get<IFileSaveService>();\n            packageBrowserService = Localizer.Kernel.Get<IPackageBrowserService>();\n            downloadManagerService = Localizer.Kernel.Get<IDownloadManagerService>();\n            pkgManager.PackageGroups = new ObservableCollection<IPackageGroup>();\n            Size = new Point(800, 340);\n            Position = new Point(40, 200);\n            Titlebar.Text = _(\"PackageManage\");\n            Titlebar.Button.MouseClick += (sender, args) => Visible = false;\n            Resizable = true;\n\n            _menuBar = new Panel\n            {\n                Dock = DockStyle.Top,\n                Size = new Point(0, 30)\n            };\n            Controls.Add(_menuBar);\n\n            AddButton(_(\"Reload\"), _(\"ReloadDesc\"), (sender, args) =>\n            {\n                if (args.Button == 0)\n                {\n                    LoadPackages();\n                }\n            });\n\n            var refreshBtn = AddButton(_(\"RefreshOnline\"), _(\"RefreshOnlineDesc\"), (sender, args) =>\n            {\n                if (args.Button == 0)\n                {\n                    RefreshOnlinePackages(sender);\n                }\n            });\n\n            AddButton(_(\"OpenFolder\"), _(\"OpenFolderDesc\"), (sender, args) =>\n            {\n                if (args.Button == 0)\n                {\n                    Process.Start($\"file://{Path.Combine(Environment.CurrentDirectory, \"Localizer\")}\");\n                }\n            });\n\n            AddButton(_(\"Export\"), _(\"ExportDesc\"), (sender, args) =>\n            {\n                if (args.Button == 0)\n                {\n                    Export(false);\n                }\n            });\n\n            AddButton(_(\"ExportWithTranslation\"), _(\"ExportWithTranslationDesc\"), (sender, args) =>\n            {\n                if (args.Button == 0)\n                {\n                    Export(true);\n                }\n            });\n\n            _split = new SplitContainer\n            {\n                Margin = new Margin(0, 10, 0, 0),\n                Dock = DockStyle.Fill\n            };\n            _split.SplitButton.Style = \"button\";\n            _split.SplitFrame1.AutoSize = AutoSize.Horizontal;\n            _split.SplitFrame2.AutoSize = AutoSize.Horizontal;\n            Controls.Add(_split);\n            _split.SplitFrame1.Controls.Add(_modList);\n            _modList.SelectedItemChanged += (sender, value) => RefreshPkgList();\n            _split.SplitFrame2.Controls.Add(_pkgList);\n            RefreshModList();\n            LoadPackages().ContinueWith(_ => RefreshOnlinePackages(refreshBtn));\n        }\n\n        private void Export(bool withTranslation)\n        {\n            try\n            {\n                if (string.IsNullOrWhiteSpace(_modList.SelectedItem?.Text ?? \"\"))\n                {\n                    return;\n                }\n\n                var name = _modList.SelectedItem.Text;\n                var mod = Localizer.GetWrappedMod(name);\n\n                var enabledPackages = pkgManager.PackageGroups\n                    .FirstOrDefault(g => g.Mod.Name == name)?.Packages\n                    .Where(p => p.Enabled)\n                    .OrderBy(p => p.ModVersion ?? new Version(0, 0, 0, 0))\n                    .ToList();\n                var oldPack = enabledPackages?.FirstOrDefault();\n\n                var package = new DataModel.Default.Package\n                {\n                    Name = oldPack?.Name ?? name,\n                    LocalizedModName = oldPack?.LocalizedModName ?? name,\n                    Language = CultureInfo.GetCultureInfo(Language.ActiveCulture.Name),\n                    ModName = name,\n                    Files = new ObservableCollection<IFile>(),\n                    Version = oldPack?.Version ?? new Version(\"1.0.0.0\"),\n                    Author = oldPack?.Author ?? \"\",\n                    Description = oldPack?.Description ?? \"\",\n                    Mod = mod,\n                    ModVersion = Version.Parse($\"{Math.Max(mod.Version.Major, 0)}.{Math.Max(mod.Version.Minor, 0)}.{Math.Max(mod.Version.Build, 0)}.{Math.Max(mod.Version.Revision, 0)}\")\n                };\n\n                var dirPath = Utils.EscapePath(Path.Combine(Localizer.SourcePackageDirPath, name));\n\n                packageExportService.Export(package, new DataModel.Default.ExportConfig\n                {\n                    WithTranslation = withTranslation\n                });\n\n                if (!Directory.Exists(dirPath))\n                {\n                    Directory.CreateDirectory(dirPath);\n                }\n\n                if (enabledPackages != null && enabledPackages.Count > 0)\n                {\n                    oldPack.ModVersion = package.ModVersion;\n                    var updateLogger = Localizer.Kernel.Get<IUpdateLogger>();\n                    updateLogger.Init($\"{package.Name}-{Utils.DateTimeToFileName(DateTime.Now)}\");\n\n                    foreach (var item in enabledPackages.Skip(1))\n                    {\n                        packageUpdateService.Update(oldPack, item, updateLogger);\n                    }\n\n                    packageUpdateService.Update(oldPack, package, updateLogger);\n\n                    packageSaveService.Save(oldPack, dirPath, fileSaveService);\n                }\n                else\n                {\n                    packageSaveService.Save(package, dirPath, fileSaveService);\n                }\n            }\n            catch (Exception e)\n            {\n                Localizer.Log.Error(e);\n            }\n        }\n\n        private Task RefreshOnlinePackages(Control sender)\n        {\n            return Task.Run(() =>\n            {\n                try\n                {\n                    loading = true;\n                    sender.Enabled = false;\n                    onlinePackages?.Clear();\n                    onlinePackages = packageBrowserService.GetList().ToList();\n                }\n                catch\n                {\n                }\n                finally\n                {\n                    loading = false;\n                    sender.Enabled = true;\n                    RefreshPkgList();\n                }\n            });\n        }\n\n        private Task LoadPackages()\n        {\n            return Task.Run(() =>\n            {\n                try\n                {\n                    loading = true;\n                    pkgManager.PackageGroups = new List<IPackageGroup>();\n                    foreach (var dir in new DirectoryInfo(Localizer.SourcePackageDirPath).GetDirectories())\n                    {\n                        try\n                        {\n                            var package2 = sourcePackageLoadServiceService.Load(dir.FullName, fileLoadService);\n                            if (package2 != null)\n                            {\n                                pkgManager.AddPackage(package2);\n                            }\n                        }\n                        catch\n                        {\n                        }\n                    }\n\n                    var list = Directory.GetFiles(Localizer.DownloadPackageDirPath).ToList();\n                    list.AddRange(Directory.GetFiles(Path.Combine(Terraria.Main.SavePath, \"Mods\"), \"*.locpack\"));\n                    foreach (var file in list)\n                    {\n                        try\n                        {\n                            var package = packedPackageLoadServiceService.Load(file, fileLoadService);\n                            if (package != null)\n                            {\n                                pkgManager.AddPackage(package);\n                            }\n                        }\n                        catch\n                        {\n                        }\n                    }\n                    pkgManager.LoadState();\n                }\n                catch (Exception o)\n                {\n                    Utils.LogError(o);\n                }\n                finally\n                {\n                    loading = false;\n                    RefreshPkgList();\n                }\n            });\n        }\n\n        private object refreshLock = new object();\n        private void RefreshPkgList()\n        {\n            string TrimEndingZero(string input)\n            {\n                while (input.EndsWith(\".0\"))\n                {\n                    input = input.Substring(0, input.Length - 2);\n                }\n                return input;\n            }\n\n            lock (refreshLock)\n            {\n                UIModsPatch.ModsExtraInfo = pkgManager.PackageGroups.ToDictionary(group => group.Mod.Name,\n                     group =>\n                     {\n                         var localizedModName = group.Packages.FirstOrDefault(pack => !string.IsNullOrWhiteSpace(pack.LocalizedModName))?.LocalizedModName;\n                         return $\"{localizedModName}{Environment.NewLine}{string.Join(Environment.NewLine, group.Packages.Select(UI.GetPkgLabelText))}\";\n                     });\n\n                var modName = _modList.SelectedItem?.Text ?? \"\";\n                try\n                {\n                    _split.SplitFrame2.Controls.Clear();\n                    _pkgList.Items.Clear();\n                    _split.SplitFrame2.Controls.Add(_pkgList);\n                    var packageGroup = pkgManager.PackageGroups.FirstOrDefault(g => g.Mod.Name == modName)?.Packages.ToList();\n                    var onlineGroup = onlinePackages.Where(g => g.ModName == modName).ToList();\n                    var displayedPackages = new Dictionary<string, ListBoxItem>();\n\n                    if (packageGroup != null)\n                    {\n                        foreach (var p in packageGroup)\n                        {\n                            // TODO: Use better key for HashSet\n                            var item = new ListBoxItem\n                            {\n                                Text = UI.GetPkgLabelText(p),\n                                Tooltip = (Gui.Renderer as UIRenderer).WordWrap(p.Description, 400),\n                                TextWrap = true,\n                                Dock = DockStyle.Top,\n                                AutoSize = AutoSize.Vertical\n                            };\n                            item.MouseClick += (sender, args) =>\n                            {\n                                if (args.Button == 0)\n                                {\n                                    UIModsPatch.ReloadRequired = true;\n                                    p.Enabled = !p.Enabled;\n                                    item.Text = UI.GetPkgLabelText(p);\n                                    pkgManager.SaveState();\n                                }\n                            };\n                            displayedPackages.Add(TrimEndingZero($\"{p.ModName}_{p.Author}_{p.Version}\"), item);\n                            _pkgList.Items.Add(item);\n                        }\n                    }\n\n                    if (onlineGroup != null)\n                    {\n                        foreach (var p in onlineGroup)\n                        {\n                            if (displayedPackages.ContainsKey(TrimEndingZero($\"{p.ModName}_{p.Author}_{p.Version}\")))\n                            {\n                                continue;\n                            }\n                            var update = displayedPackages.Any(kvp => kvp.Key.StartsWith($\"{p.ModName}_{p.Author}_\"));\n                            if (update)\n                            {\n                                var existing = displayedPackages.FirstOrDefault(kvp => kvp.Key.StartsWith($\"{p.ModName}_{p.Author}_\")).Key.Substring($\"{p.ModName}_{p.Author}_\".Length);\n                                if (Version.TryParse(existing, out var localVer) && localVer >= p.Version)\n                                {\n                                    update = false;\n                                }\n                            }\n                            var item = new ListBoxItem\n                            {\n                                Text = _(\"PackageDisplay\", _(update ? \"PackageUpdate\" : \"PackageOnline\"), p.Name, p.Version, p.Author),\n                                Tooltip = (Gui.Renderer as UIRenderer).WordWrap(p.Description, 400),\n                                TextWrap = true,\n                                Dock = DockStyle.Top,\n                                AutoSize = AutoSize.Vertical\n                            };\n                            item.MouseClick += (sender, args) => DownloadPackage(args, p);\n                            displayedPackages.Add(TrimEndingZero($\"{p.ModName}_{p.Author}_{p.Version}\"), item);\n                            _pkgList.Items.Add(item);\n                        }\n                    }\n\n                    if (displayedPackages.Count == 0)\n                    {\n                        _split.SplitFrame2.Controls.Add(new Label\n                        {\n                            Text = _(loading ? \"PackageLoading\" : \"NoPackageFound\"),\n                            TextWrap = true,\n                            AutoSize = AutoSize.Vertical,\n                            Dock = DockStyle.Fill,\n                            AllowFocus = false\n                        });\n                    }\n                }\n                catch (Exception o)\n                {\n                    Utils.LogError(o);\n                }\n            }\n        }\n\n        private void DownloadPackage(MouseEventArgs args, IPackage p)\n        {\n            if (args.Button == 0)\n            {\n                Task.Run(() =>\n                {\n                    try\n                    {\n                        Utils.LogDebug($\"Requesting {p.Name} download\");\n                        var url = packageBrowserService.GetDownloadLinkOf(p);\n                        var path = Utils.EscapePath(Path.Combine(Localizer.DownloadPackageDirPath, $\"{p.Name}_{p.Author}.locpack\"));\n                        downloadManagerService.Download(url, path);\n                        UIModsPatch.ReloadRequired = true;\n                        Utils.LogDebug($\"{p.Name} is downloaded\");\n                        LoadPackages();\n                    }\n                    catch\n                    {\n                    }\n                });\n            }\n        }\n\n        private void RefreshModList()\n        {\n            _modList.Items.Clear();\n            foreach (var loadedMod in Utils.GetLoadedMods())\n            {\n                if (loadedMod != null && loadedMod.Name != Localizer.LoadedLocalizer.Name)\n                {\n                    _modList.Items.Add(new ListBoxItem\n                    {\n                        Text = loadedMod.Name,\n                        Tooltip = $\"{loadedMod.DisplayName} (v{loadedMod.Version})\"\n                    });\n                }\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "Localizer/UIs/Stylesheet.cs",
    "content": "using System.Collections.Generic;\nusing Squid;\n\nnamespace Localizer.UIs\n{\n    public class Stylesheet\n    {\n        public static Skin GetSkin()\n        {\n            var skin = new Skin();\n\n            foreach (var s in GetControlStyles())\n            {\n                skin.Add(s.Key, s.Value);\n            }\n\n            return skin;\n        }\n\n        public static CursorCollection GetCursorSet()\n        {\n            var cursorSize = new Point(32, 32);\n            var halfSize = cursorSize / 2;\n            return new CursorCollection()\n            {\n                {CursorNames.Default, new Cursor { Texture = GetTexturePath(\"Cursors/Arrow\"), Size = cursorSize, HotSpot = Point.Zero }},\n                {CursorNames.Link, new Cursor { Texture = GetTexturePath(\"Cursors/Link\"), Size = cursorSize, HotSpot = Point.Zero }},\n                {CursorNames.Move, new Cursor { Texture = GetTexturePath(\"Cursors/Move\"), Size = cursorSize, HotSpot = halfSize }},\n                {CursorNames.Select, new Cursor { Texture = GetTexturePath(\"Cursors/Select\"), Size = cursorSize, HotSpot = halfSize }},\n                {CursorNames.SizeNS, new Cursor { Texture = GetTexturePath(\"Cursors/SizeNS\"), Size = cursorSize, HotSpot = halfSize }},\n                {CursorNames.SizeWE, new Cursor { Texture = GetTexturePath(\"Cursors/SizeWE\"), Size = cursorSize, HotSpot = halfSize }},\n                {CursorNames.HSplit, new Cursor { Texture = GetTexturePath(\"Cursors/SizeNS\"), Size = cursorSize, HotSpot = halfSize }},\n                {CursorNames.VSplit, new Cursor { Texture = GetTexturePath(\"Cursors/SizeWE\"), Size = cursorSize, HotSpot = halfSize }},\n                {CursorNames.SizeNESW, new Cursor { Texture = GetTexturePath(\"Cursors/SizeNESW\"), Size = cursorSize, HotSpot = halfSize }},\n                {CursorNames.SizeNWSE, new Cursor { Texture = GetTexturePath(\"Cursors/SizeNWSE\"), Size = cursorSize, HotSpot = halfSize }},\n            };\n        }\n        private static Dictionary<string, ControlStyle> GetControlStyles()\n        {\n            var baseStyle = new ControlStyle()\n            {\n                Tiling = TextureMode.Grid,\n                Grid = new Margin(3),\n                Texture = GetTexturePath(\"button_hot\"),\n                Default =\n                {\n                    Texture = GetTexturePath(\"button_default\"),\n                },\n                Pressed =\n                {\n                    Texture = GetTexturePath(\"button_down\"),\n                },\n                Selected =\n                {\n                    Texture = GetTexturePath(\"button_down\"),\n                },\n                Focused =\n                {\n                    Texture = GetTexturePath(\"button_down\"),\n                },\n                SelectedPressed =\n                {\n                    Texture = GetTexturePath(\"button_down\"),\n                },\n                SelectedHot =\n                {\n                    Texture = GetTexturePath(\"button_down\"),\n                },\n            };\n\n            return new Dictionary<string, ControlStyle>()\n            {\n                {\"item\", new ControlStyle(baseStyle)\n                {\n                    TextPadding = new Margin(8, 0, 8, 0),\n                    TextAlign = Alignment.MiddleLeft,\n                }},\n                {\"button\", new ControlStyle(baseStyle)\n                {\n                    TextPadding = new Margin(0),\n                    TextAlign = Alignment.MiddleCenter,\n                }},\n                {\"tooltip\", new ControlStyle(baseStyle)\n                {\n                    TextPadding = new Margin(8),\n                    TextAlign = Alignment.TopLeft,\n                }},\n                {\"textbox\", new ControlStyle(baseStyle)\n                {\n                    Texture = GetTexturePath(\"input_default\"),\n                    TextPadding = new Margin(8),\n                    Tiling = TextureMode.Grid,\n                    Grid = new Margin(3),\n                    Hot =\n                    {\n                        Texture = GetTexturePath(\"input_focused\")\n                    },\n                    Focused =\n                    {\n                        Texture = GetTexturePath(\"input_focused\"),\n                        Tint = ColorInt.ARGB(1, 1, 0, 0),\n                    },\n                }},\n                {\"window\", new ControlStyle()\n                {\n                    Tiling = TextureMode.Grid,\n                    Grid = new Margin(9),\n                    Texture = GetTexturePath(\"window\"),\n                }},\n                {\"frame\", new ControlStyle()\n                {\n                    Tiling = TextureMode.Grid,\n                    Grid = new Margin(4),\n                    Texture = GetTexturePath(\"frame\"),\n                    TextPadding = new Margin(8),\n                }},\n                {\"vscrollTrack\", new ControlStyle()\n                {\n                    Tiling = TextureMode.Grid,\n                    Grid = new Margin(3),\n                    Texture = GetTexturePath(\"vscroll_track\"),\n                }},\n                {\"vscrollButton\", new ControlStyle()\n                {\n                    Tiling = TextureMode.Grid,\n                    Grid = new Margin(3),\n                    Texture = GetTexturePath(\"vscroll_button\"),\n                    Hot =\n                    {\n                        Texture = GetTexturePath(\"vscroll_button_hot\"),\n                    },\n                    Pressed =\n                    {\n                        Texture = GetTexturePath(\"vscroll_button_down\"),\n                    },\n                }},\n                {\"vscrollUp\", new ControlStyle()\n                {\n                    Default =\n                    {\n                        Texture = GetTexturePath(\"vscrollUp_default\"),\n                    },\n                    Hot =\n                    {\n                        Texture = GetTexturePath(\"vscrollUp_hot\"),\n                    },\n                    Pressed =\n                    {\n                        Texture = GetTexturePath(\"vscrollUp_down\"),\n                    },\n                    Focused =\n                    {\n                        Texture = GetTexturePath(\"vscrollUp_hot\"),\n                    },\n                }},\n                {\"hscrollTrack\", new ControlStyle()\n                {\n                    Tiling = TextureMode.Grid,\n                    Grid = new Margin(3),\n                    Texture = GetTexturePath(\"hscroll_track\"),\n                }},\n                {\"hscrollButton\", new ControlStyle()\n                {\n                    Tiling = TextureMode.Grid,\n                    Grid = new Margin(3),\n                    Texture = GetTexturePath(\"hscroll_button\"),\n                    Hot =\n                    {\n                        Texture = GetTexturePath(\"hscroll_button_hot\"),\n                    },\n                    Pressed =\n                    {\n                        Texture = GetTexturePath(\"hscroll_button_down\"),\n                    },\n                }},\n                {\"hscrollUp\", new ControlStyle()\n                {\n                    Default =\n                    {\n                        Texture = GetTexturePath(\"hscrollUp_default\"),\n                    },\n                    Hot =\n                    {\n                        Texture = GetTexturePath(\"hscrollUp_hot\"),\n                    },\n                    Pressed =\n                    {\n                        Texture = GetTexturePath(\"hscrollUp_down\"),\n                    },\n                    Focused =\n                    {\n                        Texture = GetTexturePath(\"hscrollUp_hot\"),\n                    },\n                }},\n                {\"checkBox\", new ControlStyle()\n                {\n                    Default =\n                    {\n                        Texture = GetTexturePath(\"checkbox_default\"),\n                    },\n                    Hot =\n                    {\n                        Texture = GetTexturePath(\"checkbox_hot\"),\n                    },\n                    Pressed =\n                    {\n                        Texture = GetTexturePath(\"checkbox_down\"),\n                    },\n                    Checked =\n                    {\n                        Texture = GetTexturePath(\"checkbox_checked\"),\n                    },\n                    CheckedFocused =\n                    {\n                        Texture = GetTexturePath(\"checkbox_checked_hot\"),\n                    },\n                    CheckedHot =\n                    {\n                        Texture = GetTexturePath(\"checkbox_checked_hot\"),\n                    },\n                    CheckedPressed =\n                    {\n                        Texture = GetTexturePath(\"checkbox_down\"),\n                    },\n                }},\n                {\"comboLabel\", new ControlStyle()\n                {\n                    TextPadding = new Margin(10, 0, 0, 0),\n                    Tiling = TextureMode.Grid,\n                    Grid = new Margin(3, 0, 0, 0),\n                    Default =\n                    {\n                        Texture = GetTexturePath(\"combo_default\"),\n                    },\n                    Hot =\n                    {\n                        Texture = GetTexturePath(\"combo_hot\"),\n                    },\n                    Pressed =\n                    {\n                        Texture = GetTexturePath(\"combo_down\"),\n                    },\n                    Focused =\n                    {\n                        Texture = GetTexturePath(\"combo_hot\"),\n                    },\n                }},\n                {\"comboButton\", new ControlStyle()\n                {\n                    Default =\n                    {\n                        Texture = GetTexturePath(\"combo_button_default\"),\n                    },\n                    Hot =\n                    {\n                        Texture = GetTexturePath(\"combo_button_hot\"),\n                    },\n                    Pressed =\n                    {\n                        Texture = GetTexturePath(\"combo_button_down\"),\n                    },\n                    Focused =\n                    {\n                        Texture = GetTexturePath(\"combo_button_hot\"),\n                    },\n                }},\n                {\"multiline\", new ControlStyle()\n                {\n                    TextPadding = new Margin(8),\n                    TextAlign = Alignment.TopLeft,\n                }},\n                {\"label\", new ControlStyle()\n                {\n                    TextPadding = new Margin(8, 0, 8, 0),\n                    TextAlign = Alignment.MiddleLeft,\n                    TextColor = ColorInt.ARGB(1, .8f, .8f, .8f),\n                    BackColor = 0,\n                }},\n            };\n        }\n\n        private static string GetTexturePath(string name)\n        {\n            return $\"UIs/Assets/{name}\";\n        }\n    }\n}\n"
  },
  {
    "path": "Localizer/UIs/UIDesktop.cs",
    "content": "using Localizer.UIs.Views;\nusing Squid;\n\nnamespace Localizer.UIs\n{\n    public class UIDesktop : Desktop\n    {\n        public TestView TestView;\n        public ReloadPluginView ReloadPluginView;\n        public UIDesktop()\n        {\n            //            TestView = new TestView();\n            //            TestView.Parent = this;\n\n            //ReloadPluginView = new ReloadPluginView\n            //{\n            //Parent = this\n            //};\n        }\n\n        public void AddWindow(Window window)\n        {\n            window.Parent = this;\n        }\n    }\n}\n"
  },
  {
    "path": "Localizer/UIs/UIHost.cs",
    "content": "using Microsoft.Xna.Framework;\nusing Microsoft.Xna.Framework.Graphics;\nusing Microsoft.Xna.Framework.Input;\nusing Squid;\nusing Terraria;\nusing ButtonState = Microsoft.Xna.Framework.Input.ButtonState;\n\nnamespace Localizer.UIs\n{\n    public class UIHost : Disposable\n    {\n        public UIDesktop Desktop { get; private set; }\n\n        private int _lastScroll;\n\n        private GraphicsDevice gd;\n\n        public UIHost()\n        {\n            gd = Main.graphics.GraphicsDevice;\n\n            Gui.Renderer = new UIRenderer();\n\n            Desktop = new UIDesktop { Name = \"localizer\" };\n            Desktop.ShowCursor = true;\n            Desktop.Skin = Stylesheet.GetSkin();\n            Desktop.Size = new Squid.Point(gd.Viewport.Width, gd.Viewport.Height);\n        }\n\n        internal void Update(GameTime time)\n        {\n            Gui.TimeElapsed = (float)time.ElapsedGameTime.TotalMilliseconds;\n\n            if (Main.graphics.GraphicsDevice.Viewport.Width != Desktop.Size.x || Main.graphics.GraphicsDevice.Viewport.Height != Desktop.Size.y)\n            {\n                Desktop.Size = new Squid.Point(gd.Viewport.Width, gd.Viewport.Height);\n            }\n\n            if (!Main.hasFocus)\n            {\n                return;\n            }\n\n            // Mouse\n            var mouseState = Mouse.GetState();\n\n            var wheel = mouseState.ScrollWheelValue > _lastScroll ? -1 : (mouseState.ScrollWheelValue < _lastScroll ? 1 : 0);\n            _lastScroll = mouseState.ScrollWheelValue;\n\n            Gui.SetMouse(mouseState.X, mouseState.Y, wheel);\n            Gui.SetButtons(mouseState.LeftButton == ButtonState.Pressed, mouseState.RightButton == ButtonState.Pressed);\n\n            //TODO: Keyboard Input Support\n        }\n\n        internal void Draw(GameTime time)\n        {\n            Desktop.Update();\n            Desktop.Draw();\n        }\n\n        protected override void DisposeUnmanaged()\n        {\n            Gui.Renderer = null;\n        }\n    }\n}\n"
  },
  {
    "path": "Localizer/UIs/UIModsPatch.cs",
    "content": "using System;\nusing System.Collections.Generic;\nusing System.Reflection;\nusing Harmony;\nusing Microsoft.Xna.Framework;\nusing Microsoft.Xna.Framework.Graphics;\nusing Terraria;\nusing Terraria.GameContent.UI.Elements;\nusing Terraria.Localization;\nusing Terraria.UI.Chat;\nusing static Localizer.Lang;\n\nnamespace Localizer.UIs\n{\n    internal static class UIModsPatch\n    {\n        internal static bool ReloadRequired;\n        private static int frameCounter;\n        internal static Dictionary<string, string> ModsExtraInfo;\n\n        public static void Patch()\n        {\n            ReloadRequired = false;\n            frameCounter = 0;\n            if (ModsExtraInfo == null)\n            {\n                ModsExtraInfo = new Dictionary<string, string>();\n            }\n\n            var refHolder = false;\n            Localizer.Harmony.Patch(\"Terraria.ModLoader.Config.ConfigManager\", \"ModNeedsReload\",\n                postfix: NoroHelper.HarmonyMethod(() => ModNeedsReloadPostfix(ref refHolder)));\n\n            Localizer.Harmony.Patch(\"Terraria.ModLoader.UI.UIModItem\", \"OnInitialize\",\n                postfix: NoroHelper.HarmonyMethod(() => UIModItemPostfix(null)));\n\n            Localizer.Harmony.Patch(\"Terraria.ModLoader.UI.UIModItem\", \"DrawSelf\",\n                postfix: NoroHelper.HarmonyMethod(() => DrawSelfPostfix(null, null)));\n\n            Localizer.Harmony.Patch(\"Terraria.ModLoader.UI.ModBrowser.UIModBrowser\", \"PopulateFromJson\",\n                prefix: NoroHelper.HarmonyMethod(() => PopulateFromJsonPrefix()),\n                postfix: NoroHelper.HarmonyMethod(() => PopulateFromJsonPostfix()));\n        }\n\n        private static void PopulateFromJsonPrefix()\n        {\n            Localizer.LoadedLocalizer.File.SetField(\"<name>k__BackingField\", \"Localizer\");\n            Localizer.LoadedLocalizer.SetField(\"name\", \"Localizer\");\n        }\n\n        private static void PopulateFromJsonPostfix()\n        {\n            Localizer.LoadedLocalizer.File.SetField(\"<name>k__BackingField\", \"!Localizer\");\n            Localizer.LoadedLocalizer.SetField(\"name\", \"!Localizer\");\n        }\n\n        private static void ModNeedsReloadPostfix(ref bool __result)\n        {\n            if (ReloadRequired)\n            {\n                __result = true;\n            }\n        }\n\n        private static void DrawSelfPostfix(object __instance, SpriteBatch spriteBatch)\n        {\n            var current = __instance as UIPanel;\n            var modName = __instance.ValueOf(\"_mod\")?.ValueOf(\"Name\")?.ToString();\n            var modNameHovering = current.ValueOf<UIText>(\"_modName\")?.IsMouseHovering ?? false;\n            if (modName == \"!Localizer\")\n            {\n                frameCounter++;\n\n                current.ValueOf<UIText>(\"_modName\")\n                       .SetField(\"_text\",\n                                 $\"{Utils.AsRainbow(\"Localizer\", frameCounter)} v{current.ValueOf(\"_mod\").ValueOf(\"modFile\").ValueOf(\"version\")}\");\n\n                var tooltip = \"\";\n                if (modNameHovering)\n                {\n                    var modAuthor = current.ValueOf(\"_mod\")?.ValueOf(\"properties\").ValueOf<string>(\"author\");\n                    if (modAuthor.Length > 0)\n                    {\n                        tooltip = _(\"OpenUI\",\n                            Language.GetTextValue(\"tModLoader.ModsByline\", Utils.AsRainbow(modAuthor, frameCounter + 150, 9)),\n                            $\"{Utils.AsRainbow(\"Localizer\", frameCounter)}\");\n                    }\n                }\n\n                if (!string.IsNullOrEmpty(tooltip))\n                {\n                    current.SetField(\"_tooltip\", \"\");\n                    var snippets = ChatManager.ParseMessage(tooltip, Color.White).ToArray();\n                    var x = ChatManager.GetStringSize(Main.fontMouseText, snippets, Vector2.One).X;\n                    var pos = Main.MouseScreen + new Vector2(16f);\n                    pos.X = Math.Min(pos.X, Main.screenWidth - x - 16f);\n                    pos.Y = Math.Min(pos.Y, Main.screenHeight - 30);\n                    ChatManager.DrawColorCodedStringWithShadow(spriteBatch, Main.fontMouseText,\n                      snippets, pos, 0, Vector2.Zero, Vector2.One, out var _);\n                }\n            }\n            else if (modNameHovering && ModsExtraInfo.ContainsKey(modName))\n            {\n                current.SetField(\"_tooltip\", current.ValueOf<string>(\"_tooltip\") + Environment.NewLine + ModsExtraInfo[modName]);\n            }\n        }\n\n        private static void UIModItemPostfix(object __instance)\n        {\n            var modName = __instance.ValueOf(\"_mod\")?.ValueOf(\"Name\")?.ToString();\n            if (modName == \"!Localizer\")\n            {\n                __instance.ValueOf<UIText>(\"_modName\").OnClick += (evt, element) =>\n                {\n                    if (Localizer.PackageUI != null)\n                    {\n                        Localizer.PackageUI.Visible = true;\n                    }\n                    else\n                    {\n                        Localizer.PackageUI = new MainWindow();\n                        Localizer.Instance.UIHost.Desktop.AddWindow(Localizer.PackageUI);\n                    }\n                };\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "Localizer/UIs/UIRenderer.cs",
    "content": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Reflection;\nusing Localizer.Helpers;\nusing Microsoft.Xna.Framework;\nusing Microsoft.Xna.Framework.Graphics;\nusing ReLogic.Graphics;\nusing Squid;\nusing Terraria;\nusing Terraria.UI.Chat;\nusing Point = Squid.Point;\nusing Rectangle = Microsoft.Xna.Framework.Rectangle;\n\nnamespace Localizer.UIs\n{\n    public class UIRenderer : ISquidRenderer\n    {\n        private SpriteBatch _spriteBatch;\n\n        private Dictionary<string, int> textureIDs;\n        private Dictionary<int, Texture2D> textures;\n        private Dictionary<string, int> fontIDs;\n        private Dictionary<int, DynamicSpriteFont> fonts;\n\n        private Texture2D _blankTexture;\n        private RasterizerState _rasterizer;\n        private SamplerState _sampler;\n\n        public UIRenderer()\n        {\n            _spriteBatch = new SpriteBatch(Main.graphics.GraphicsDevice);\n\n            _blankTexture = new Texture2D(_spriteBatch.GraphicsDevice, 1, 1);\n            _blankTexture.SetData(new[] { new Color(255, 255, 255, 255) });\n\n            textureIDs = new Dictionary<string, int>();\n            textures = new Dictionary<int, Texture2D>();\n            fontIDs = new Dictionary<string, int>();\n            fonts = new Dictionary<int, DynamicSpriteFont>();\n\n            var modTextures = Localizer.Instance.ValueOf<IDictionary<string, Texture2D>>(\"textures\");\n            foreach (var t in modTextures)\n            {\n                AddTexture(t.Key, t.Value);\n            }\n\n            AddFont(\"default\", Main.fontMouseText);\n            AddFont(\"mouse\", Main.fontMouseText);\n            AddFont(\"item\", Main.fontItemStack);\n            AddFont(\"death\", Main.fontDeathText);\n\n            _rasterizer = new RasterizerState\n            {\n                ScissorTestEnable = true\n            };\n\n            _sampler = new SamplerState\n            {\n                Filter = TextureFilter.Anisotropic\n            };\n        }\n\n        public void AddFont(string key, DynamicSpriteFont font)\n        {\n            var index = fontIDs.Count;\n            fontIDs.Add(key, index);\n            fonts.Add(index, font);\n        }\n\n        public void AddTexture(string key, Texture2D tex)\n        {\n            var index = textureIDs.Count;\n            textureIDs.Add(key, index);\n            textures.Add(index, tex);\n        }\n\n        public void Dispose()\n        {\n        }\n\n        public int GetTexture(string name)\n        {\n            return textureIDs[name];\n        }\n\n        public int GetFont(string name)\n        {\n            return fontIDs[name];\n        }\n\n        public Point GetTextSize(string text, int font)\n        {\n            var size = ChatManager.GetStringSize(fonts[fontIDs[\"default\"]], text, new Vector2(1));\n            return new Point((int)size.X, (int)size.Y);\n        }\n\n        public string WordWrap(string text, int width)\n        {\n            var result = Terraria.Utils.WordwrapStringSmart(text, Color.White, fonts[fontIDs[\"default\"]], width, -1);\n            return string.Join(Environment.NewLine, result.Select(line => string.Join(\"\", line.Select(ts => ts.Text))));\n        }\n\n        public Point GetTextureSize(int texture)\n        {\n            var tex = textures[texture];\n            return new Point(tex.Width, tex.Height);\n        }\n\n        public void Scissor(int x, int y, int w, int h)\n        {\n            Main.graphics.GraphicsDevice.ScissorRectangle\n                = new Rectangle(Math.Max(x, 0), Math.Max(y, 0), Math.Min(w, Main.screenWidth), Math.Min(h, Main.screenHeight));\n        }\n\n        public void DrawBox(int x, int y, int w, int h, int color)\n        {\n            var rect = new Rectangle(x, y, w, h);\n            _spriteBatch.Draw(_blankTexture, rect, rect, ColorFromtInt32(color));\n        }\n\n        private Color ColorFromtInt32(int color)\n        {\n            var bytes = BitConverter.GetBytes(color);\n            return new Color(bytes[2], bytes[1], bytes[0], bytes[3]);\n        }\n\n        public void DrawText(string text, int x, int y, int font, int color)\n        {\n            var snippets = ChatManager.ParseMessage(text, ColorFromtInt32(color)).ToArray();\n            // Terraria.Utils.DrawBorderStringFourWay(_spriteBatch,\n            //                                        fonts[font], text, x, y + 3,\n            //                                        ColorFromtInt32(color),\n            //                                        Color.Black, Vector2.Zero, 1f);\n            ChatManager.DrawColorCodedString(\n                _spriteBatch, fonts[font], snippets, new Vector2(x, y + 3),\n                ColorFromtInt32(color), 0, Vector2.Zero, Vector2.One, out var i, 99999);\n        }\n\n        public void DrawTexture(int texture, int x, int y, int w, int h, Squid.Rectangle rect, int color)\n        {\n            var destination = new Rectangle(x, y, w, h);\n            var source = new Rectangle(rect.Left, rect.Top, rect.Width, rect.Height);\n            _spriteBatch.Draw(textures[texture], destination, source, ColorFromtInt32(color));\n        }\n\n        public bool TranslateKey(int scancode, ref char character)\n        {\n            character = ' ';\n            return true;\n        }\n\n        public void StartBatch()\n        {\n            _spriteBatch.SafeBegin();\n        }\n\n        public void EndBatch(bool final)\n        {\n            _spriteBatch.SafeEnd();\n        }\n    }\n}\n"
  },
  {
    "path": "Localizer/UIs/Views/ManagerView.cs",
    "content": "namespace Localizer.UIs.Views\n{\n}\n"
  },
  {
    "path": "Localizer/UIs/Views/ReloadPluginView.cs",
    "content": "using Localizer.UIs.Components;\nusing Squid;\n\nnamespace Localizer.UIs.Views\n{\n    public class ReloadPluginView : BasicWindow\n    {\n        public ReloadPluginView()\n        {\n            Size = new Point(40, 40);\n            Position = new Point(0, 0);\n            Resizable = false;\n\n            var reloadPlugins = new Button()\n            {\n                Size = new Point(40, 40),\n                Style = \"button\",\n            };\n\n            reloadPlugins.MouseClick += (sender, args) =>\n            {\n                Localizer.Kernel.UnloadAllPlugins();\n                Localizer.Kernel.LoadPlugins();\n            };\n\n            Controls.Add(reloadPlugins);\n        }\n    }\n}\n"
  },
  {
    "path": "Localizer/UIs/Views/TestView.cs",
    "content": "using Localizer.UIs.Components;\nusing Squid;\n\nnamespace Localizer.UIs.Views\n{\n    public class TestView : BasicWindow\n    {\n        public TestView()\n        {\n            Size = new Point(440, 340);\n            Position = new Point(40, 40);\n            Titlebar.Text = \"[color=FfFfFf00]BBCode[/color]中文测试\";\n            Resizable = true;\n\n            var label1 = new Label\n            {\n                Text = \"Username:\",\n                Size = new Point(122, 35),\n                Position = new Point(60, 100),\n                Parent = this\n            };\n\n            label1.MousePress += (sender, args) =>\n            {\n            };\n\n            var textbox1 = new TextBox { Name = \"textbox\" };\n            textbox1.Text = \"username\";\n            textbox1.Size = new Point(222, 35);\n            textbox1.Position = new Point(180, 100);\n            textbox1.Style = \"textbox\";\n            textbox1.Parent = this;\n            textbox1.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right;\n\n            var label2 = new Label\n            {\n                Text = \"Password:\",\n                Size = new Point(122, 35),\n                Position = new Point(60, 140),\n                Parent = this\n            };\n\n            var textbox2 = new TextBox { Name = \"textbox\" };\n            textbox2.PasswordChar = char.Parse(\"*\");\n            textbox2.IsPassword = true;\n            textbox2.Text = \"password\";\n            textbox2.Size = new Point(222, 35);\n            textbox2.Position = new Point(180, 140);\n            textbox2.Style = \"textbox\";\n            textbox2.Parent = this;\n            textbox2.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right;\n\n            var button = new Button\n            {\n                Size = new Point(157, 35),\n                Position = new Point(437 - 192, 346 - 52),\n                Text = \"Login\",\n                Style = \"button\",\n                Parent = this,\n                Anchor = AnchorStyles.Bottom | AnchorStyles.Right,\n                Cursor = CursorNames.Link\n            };\n            button.MouseClick += (sender, args) =>\n            {\n            };\n\n            var combo = new DropDownList\n            {\n                Size = new Point(222, 35),\n                Position = new Point(180, 180),\n                Parent = this\n            };\n            combo.Label.Style = \"comboLabel\";\n            combo.Button.Style = \"comboButton\";\n            combo.Listbox.Margin = new Margin(0, 6, 0, 0);\n            combo.Listbox.Style = \"frame\";\n            combo.Listbox.ClipFrame.Margin = new Margin(8, 8, 8, 8);\n            combo.Listbox.Scrollbar.Margin = new Margin(0, 4, 4, 4);\n            combo.Listbox.Scrollbar.Size = new Point(14, 10);\n            combo.Listbox.Scrollbar.ButtonUp.Style = \"vscrollUp\";\n            combo.Listbox.Scrollbar.ButtonUp.Size = new Point(10, 20);\n            combo.Listbox.Scrollbar.ButtonDown.Style = \"vscrollUp\";\n            combo.Listbox.Scrollbar.ButtonDown.Size = new Point(10, 20);\n            combo.Listbox.Scrollbar.Slider.Margin = new Margin(0, 2, 0, 2);\n            combo.Listbox.Scrollbar.Slider.Style = \"vscrollTrack\";\n            combo.Listbox.Scrollbar.Slider.Button.Style = \"vscrollButton\";\n            combo.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right;\n\n            for (var i = 0; i < 10; i++)\n            {\n                var item = new ListBoxItem();\n                var label = new Label()\n                {\n                    Text = \"listboxitem\",\n                    Size = new Point(100, 35),\n                    Margin = new Margin(0, 0, 0, 4),\n                    Style = \"item\",\n                };\n                item.Container.Controls.Add(label);\n                combo.Items.Add(item);\n                if (i == 3)\n                {\n                    item.Selected = true;\n                }\n            }\n\n            var box = new CheckBox\n            {\n                Size = new Point(157, 26),\n                Position = new Point(180, 220),\n                Text = \"Remember me\",\n                Parent = this\n            };\n            box.Button.Style = \"checkBox\";\n            box.Button.Size = new Point(26, 26);\n            box.Button.Cursor = CursorNames.Link;\n        }\n    }\n}\n"
  },
  {
    "path": "Localizer/build.txt",
    "content": "author = Chireiden Team\nversion = 1.5.0.19\ndisplayName = Localizer\nhideCode = true\nhideResources = false\nincludeSource = false\nhomepage = https://github.com/chi-rei-den/Localizer/\nbuildIgnore = *.user, obj\\*, bin\\*, .vs\\*, .git*, referenceImages*.png, .gitattributes, *.csproj\nincludePDB = false\ndllReferences = Ninject,0Harmony,Squid\nside = NoSync"
  },
  {
    "path": "Localizer/description.txt",
    "content": "﻿Provide localization functions include:\n    - Extract texts from mods\n    - Apply translations to mods\n    - Create your own translation package\n    - Download user generated packages from Localizer\n\nCurrently this mod is in hard developing, docs and manuals are not built."
  },
  {
    "path": "Localizer.sln",
    "content": "﻿\nMicrosoft Visual Studio Solution File, Format Version 12.00\n# Visual Studio Version 16\nVisualStudioVersion = 16.0.29324.140\nMinimumVisualStudioVersion = 10.0.40219.1\nProject(\"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\") = \"Localizer\", \"Localizer\\Localizer.csproj\", \"{95D54B28-B67B-4248-B83A-B5E5426C3806}\"\n\tProjectSection(ProjectDependencies) = postProject\n\t\t{D05E5CFB-866F-43D1-BBFE-7CA84249CF36} = {D05E5CFB-866F-43D1-BBFE-7CA84249CF36}\n\tEndProjectSection\nEndProject\nProject(\"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\") = \"LocalizerTest\", \"LocalizerTest\\LocalizerTest.csproj\", \"{019C1A68-7B2C-400C-BCAE-FC9EF658A3BC}\"\nEndProject\nProject(\"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\") = \"ModPatch\", \"ModPatch\\ModPatch.csproj\", \"{D05E5CFB-866F-43D1-BBFE-7CA84249CF36}\"\nEndProject\nProject(\"{9A19103F-16F7-4668-BE54-9A1E7A4F7556}\") = \"Squid\", \"Squid\\Squid.csproj\", \"{205C6E4A-4F9C-44FE-BB81-48F9914F048F}\"\nEndProject\nGlobal\n\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\n\t\tDebug|Any CPU = Debug|Any CPU\n\t\tDebug|x86 = Debug|x86\n\t\tRelease|Any CPU = Release|Any CPU\n\t\tRelease|x86 = Release|x86\n\tEndGlobalSection\n\tGlobalSection(ProjectConfigurationPlatforms) = postSolution\n\t\t{95D54B28-B67B-4248-B83A-B5E5426C3806}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\n\t\t{95D54B28-B67B-4248-B83A-B5E5426C3806}.Debug|Any CPU.Build.0 = Debug|Any CPU\n\t\t{95D54B28-B67B-4248-B83A-B5E5426C3806}.Debug|x86.ActiveCfg = Debug|Any CPU\n\t\t{95D54B28-B67B-4248-B83A-B5E5426C3806}.Debug|x86.Build.0 = Debug|Any CPU\n\t\t{95D54B28-B67B-4248-B83A-B5E5426C3806}.Release|Any CPU.ActiveCfg = Release|Any CPU\n\t\t{95D54B28-B67B-4248-B83A-B5E5426C3806}.Release|Any CPU.Build.0 = Release|Any CPU\n\t\t{95D54B28-B67B-4248-B83A-B5E5426C3806}.Release|x86.ActiveCfg = Release|Any CPU\n\t\t{95D54B28-B67B-4248-B83A-B5E5426C3806}.Release|x86.Build.0 = Release|Any CPU\n\t\t{019C1A68-7B2C-400C-BCAE-FC9EF658A3BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\n\t\t{019C1A68-7B2C-400C-BCAE-FC9EF658A3BC}.Debug|Any CPU.Build.0 = Debug|Any CPU\n\t\t{019C1A68-7B2C-400C-BCAE-FC9EF658A3BC}.Debug|x86.ActiveCfg = Debug|Any CPU\n\t\t{019C1A68-7B2C-400C-BCAE-FC9EF658A3BC}.Debug|x86.Build.0 = Debug|Any CPU\n\t\t{019C1A68-7B2C-400C-BCAE-FC9EF658A3BC}.Release|Any CPU.ActiveCfg = Release|Any CPU\n\t\t{019C1A68-7B2C-400C-BCAE-FC9EF658A3BC}.Release|Any CPU.Build.0 = Release|Any CPU\n\t\t{019C1A68-7B2C-400C-BCAE-FC9EF658A3BC}.Release|x86.ActiveCfg = Release|Any CPU\n\t\t{019C1A68-7B2C-400C-BCAE-FC9EF658A3BC}.Release|x86.Build.0 = Release|Any CPU\n\t\t{D05E5CFB-866F-43D1-BBFE-7CA84249CF36}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\n\t\t{D05E5CFB-866F-43D1-BBFE-7CA84249CF36}.Debug|Any CPU.Build.0 = Debug|Any CPU\n\t\t{D05E5CFB-866F-43D1-BBFE-7CA84249CF36}.Debug|x86.ActiveCfg = Debug|Any CPU\n\t\t{D05E5CFB-866F-43D1-BBFE-7CA84249CF36}.Debug|x86.Build.0 = Debug|Any CPU\n\t\t{D05E5CFB-866F-43D1-BBFE-7CA84249CF36}.Release|Any CPU.ActiveCfg = Release|Any CPU\n\t\t{D05E5CFB-866F-43D1-BBFE-7CA84249CF36}.Release|Any CPU.Build.0 = Release|Any CPU\n\t\t{D05E5CFB-866F-43D1-BBFE-7CA84249CF36}.Release|x86.ActiveCfg = Release|Any CPU\n\t\t{D05E5CFB-866F-43D1-BBFE-7CA84249CF36}.Release|x86.Build.0 = Release|Any CPU\n\t\t{205C6E4A-4F9C-44FE-BB81-48F9914F048F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\n\t\t{205C6E4A-4F9C-44FE-BB81-48F9914F048F}.Debug|Any CPU.Build.0 = Debug|Any CPU\n\t\t{205C6E4A-4F9C-44FE-BB81-48F9914F048F}.Debug|x86.ActiveCfg = Debug|Any CPU\n\t\t{205C6E4A-4F9C-44FE-BB81-48F9914F048F}.Debug|x86.Build.0 = Debug|Any CPU\n\t\t{205C6E4A-4F9C-44FE-BB81-48F9914F048F}.Release|Any CPU.ActiveCfg = Release|Any CPU\n\t\t{205C6E4A-4F9C-44FE-BB81-48F9914F048F}.Release|Any CPU.Build.0 = Release|Any CPU\n\t\t{205C6E4A-4F9C-44FE-BB81-48F9914F048F}.Release|x86.ActiveCfg = Release|Any CPU\n\t\t{205C6E4A-4F9C-44FE-BB81-48F9914F048F}.Release|x86.Build.0 = Release|Any CPU\n\tEndGlobalSection\n\tGlobalSection(SolutionProperties) = preSolution\n\t\tHideSolutionNode = FALSE\n\tEndGlobalSection\n\tGlobalSection(ExtensibilityGlobals) = postSolution\n\t\tSolutionGuid = {205BC2C0-6C22-4D90-B9CA-A44D33E09BAC}\n\tEndGlobalSection\nEndGlobal\n"
  },
  {
    "path": "Localizer.sln.DotSettings",
    "content": "﻿<wpf:ResourceDictionary xml:space=\"preserve\" xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\" xmlns:s=\"clr-namespace:System;assembly=mscorlib\" xmlns:ss=\"urn:shemas-jetbrains-com:settings-storage-xaml\" xmlns:wpf=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\">\n\t<s:Boolean x:Key=\"/Default/CodeInspection/CodeAnnotations/NamespacesWithAnnotations/=TestWPF_002EAnnotations/@EntryIndexedValue\">True</s:Boolean>\n\t<s:Boolean x:Key=\"/Default/UserDictionary/Words/=Localizer/@EntryIndexedValue\">True</s:Boolean></wpf:ResourceDictionary>"
  },
  {
    "path": "LocalizerTest/DataModel/GitHubUpdateInfoTest.cs",
    "content": "using System;\nusing FluentAssertions;\nusing Localizer.DataModel;\nusing Localizer.DataModel.Default;\nusing Xunit;\n\nnamespace LocalizerTest.DataModel\n{\n    public class GitHubUpdateInfoTest\n    {\n        [Fact]\n        public void Parse_Correct()\n        {\n            var info = new GitHubUpdateInfo(\"a1.2.3.4\");\n\n            info.Type.Should().Be(UpdateType.Minor);\n            info.Version.Should().BeEquivalentTo(Version.Parse(\"1.2.3.4\"));\n        }\n    }\n}\n"
  },
  {
    "path": "LocalizerTest/Helper/ExtensionsTest.cs",
    "content": "using System;\nusing FluentAssertions;\nusing Localizer.DataModel.Default;\nusing Localizer.Helpers;\nusing Xunit;\n\nnamespace LocalizerTest.Helper\n{\n    public class ExtensionsTest\n    {\n        [Theory]\n        [InlineData(typeof(BasicItemFile), 1, \"Items\")]\n        [InlineData(typeof(BasicNPCFile), 1, \"NPCs\")]\n        [InlineData(typeof(BasicBuffFile), 1, \"Buffs\")]\n        [InlineData(typeof(BasicPrefixFile), 1, \"Prefixes\")]\n        [InlineData(typeof(BasicProjectileFile), 1, \"Projectiles\")]\n        public void ModTranslationOwnerField_Correct(Type type, int count, string name)\n        {\n            type.ModTranslationOwnerField().Length.Should().Be(count);\n            type.ModTranslationOwnerField()[0].Name.Should().Be(name);\n        }\n\n        [Fact]\n        public void ModTranslationOwnerFieldName_Correct()\n        {\n            var prop = typeof(BasicItemFile).ModTranslationOwnerField()[0];\n            prop.ModTranslationOwnerFieldName().Should().Be(\"items\");\n        }\n\n        [Fact]\n        public void ModTranslationProp_Correct()\n        {\n            var props = typeof(ItemEntry).ModTranslationProp();\n            props.Length.Should().Be(2);\n            props.Should().ContainSingle(p => p.Name == \"Name\");\n            props.Should().ContainSingle(p => p.Name == \"Tooltip\");\n        }\n    }\n}\n"
  },
  {
    "path": "LocalizerTest/Helper/UtilsTest.cs",
    "content": "using FluentAssertions;\nusing Localizer.DataModel.Default;\nusing Xunit;\nusing ModUtils = Localizer.Utils;\n\nnamespace LocalizerTest.Helper\n{\n    public class UtilsTest\n    {\n        [Fact]\n        public void CreateEntryMappings_Correct()\n        {\n            var mappings = ModUtils.CreateEntryMappings(typeof(ItemEntry));\n\n            mappings[\"DisplayName\"].Name.Should().Be(\"Name\");\n            mappings[\"Tooltip\"].Name.Should().Be(\"Tooltip\");\n        }\n\n        [Fact]\n        public void GetMethodBase_Correct()\n        {\n            var thisMethod = ModUtils.GetMethodBase<UtilsTest>(\"System.Void LocalizerTest.Helper.UtilsTest::GetMethodBase_Correct()\");\n            thisMethod.Name.Should().Be(nameof(GetMethodBase_Correct));\n        }\n\n        [Fact]\n        public void GetMethodBase_Wrong()\n        {\n            var thisMethod = ModUtils.GetMethodBase<UtilsTest>(\"\");\n            thisMethod.Should().BeNull();\n        }\n\n        [Fact]\n        public void GetTranslationEntry_Correct()\n        {\n            var testEntry = new ItemEntry\n            {\n                Name = new BaseEntry\n                {\n                    Origin = \"Test\",\n                    Translation = \"Case\"\n                },\n                Tooltip = new BaseEntry\n                {\n                    Origin = \"Test\",\n                    Translation = \"Case\"\n                }\n            };\n\n            var nameTranslation = ModUtils.GetTranslationOfEntry(testEntry, typeof(ItemEntry).GetProperty(\"Name\"));\n            nameTranslation.Should().Be(\"Case\");\n            var tooltipTranlation = ModUtils.GetTranslationOfEntry(testEntry, typeof(ItemEntry).GetProperty(\"Tooltip\"));\n            tooltipTranlation.Should().Be(\"Case\");\n        }\n    }\n}\n"
  },
  {
    "path": "LocalizerTest/LocalizerTest.cs",
    "content": "using System;\nusing FluentAssertions;\nusing Localizer;\nusing Localizer.Attributes;\nusing Xunit;\n\nnamespace LocalizerTest\n{\n    [OperationTiming(OperationTiming.BeforeModCtor)]\n    internal class FooA { }\n    [OperationTiming(OperationTiming.BeforeModLoad)]\n    internal class FooB { }\n    [OperationTiming(OperationTiming.PostContentLoad)]\n    internal class FooC { }\n    [OperationTiming(OperationTiming.Any)]\n    internal class FooD { }\n\n    internal class FooE { }\n\n    public class LocalizerTest\n    {\n        [Theory]\n        [InlineData(OperationTiming.BeforeModCtor, OperationTiming.Any)]\n        [InlineData(OperationTiming.BeforeModCtor, OperationTiming.BeforeModCtor)]\n        [InlineData(OperationTiming.BeforeModLoad, OperationTiming.Any)]\n        [InlineData(OperationTiming.BeforeModLoad, OperationTiming.BeforeModLoad)]\n        [InlineData(OperationTiming.PostContentLoad, OperationTiming.Any)]\n        [InlineData(OperationTiming.PostContentLoad, OperationTiming.PostContentLoad)]\n        [InlineData(OperationTiming.PostContentLoad, OperationTiming.PostContentLoad | OperationTiming.BeforeModLoad)]\n        public void CanDoOperationNow_True(OperationTiming state, OperationTiming operation)\n        {\n            Localizer.Localizer.State = state;\n            Localizer.Localizer.CanDoOperationNow(operation).Should().BeTrue();\n        }\n\n        [Theory]\n        [InlineData(OperationTiming.BeforeModCtor, typeof(FooA))]\n        [InlineData(OperationTiming.BeforeModLoad, typeof(FooD))]\n        [InlineData(OperationTiming.PostContentLoad, typeof(FooE))]\n        [InlineData(OperationTiming.BeforeModCtor, typeof(FooD))]\n        [InlineData(OperationTiming.BeforeModCtor, typeof(FooE))]\n        public void CanDoOperationNow_Type_True(OperationTiming state, Type t)\n        {\n            Localizer.Localizer.State = state;\n            Localizer.Localizer.CanDoOperationNow(t).Should().BeTrue();\n        }\n\n        [Theory]\n        [InlineData(OperationTiming.BeforeModCtor, OperationTiming.BeforeModLoad)]\n        [InlineData(OperationTiming.BeforeModCtor, OperationTiming.PostContentLoad)]\n        [InlineData(OperationTiming.BeforeModLoad, OperationTiming.PostContentLoad)]\n        [InlineData(OperationTiming.PostContentLoad, OperationTiming.BeforeModCtor)]\n        [InlineData(OperationTiming.PostContentLoad, OperationTiming.BeforeModCtor | OperationTiming.BeforeModLoad)]\n        public void CanDoOperationNow_False(OperationTiming state, OperationTiming operation)\n        {\n            Localizer.Localizer.State = state;\n            Localizer.Localizer.CanDoOperationNow(operation).Should().BeFalse();\n        }\n\n        [Theory]\n        [InlineData(OperationTiming.BeforeModCtor, typeof(FooB))]\n        [InlineData(OperationTiming.BeforeModCtor, typeof(FooC))]\n        [InlineData(OperationTiming.PostContentLoad, typeof(FooB))]\n        [InlineData(OperationTiming.PostContentLoad, typeof(FooA))]\n        public void CanDoOperationNow_Type_False(OperationTiming state, Type t)\n        {\n            Localizer.Localizer.State = state;\n            Localizer.Localizer.CanDoOperationNow(t).Should().BeFalse();\n        }\n    }\n}\n"
  },
  {
    "path": "LocalizerTest/LocalizerTest.csproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project Sdk=\"Microsoft.NET.Sdk\">\n  <Import Project=\"$(USERPROFILE)\\Documents\\My Games\\Terraria\\ModLoader\\references\\tModLoader.targets\" />\n  <PropertyGroup>\n    <ProjectGuid>{019C1A68-7B2C-400C-BCAE-FC9EF658A3BC}</ProjectGuid>\n    <ProjectTypeGuids>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>\n    <AssemblyName>LocalizerTest</AssemblyName>\n    <TargetFramework>net472</TargetFramework>\n    <PlatformTarget>x86</PlatformTarget>\n    <LangVersion>7.3</LangVersion>\n  </PropertyGroup>\n  <ItemGroup>\n    <ProjectReference Include=\"..\\Localizer\\Localizer.csproj\">\n      <Project>{95d54b28-b67b-4248-b83a-b5e5426c3806}</Project>\n      <Name>Localizer</Name>\n    </ProjectReference>\n  </ItemGroup>\n  <ItemGroup>\n    <PackageReference Include=\"FluentAssertions\">\n      <Version>5.9.0</Version>\n    </PackageReference>\n    <PackageReference Include=\"Ninject\">\n      <Version>3.3.4</Version>\n    </PackageReference>\n    <PackageReference Include=\"xunit\">\n      <Version>2.4.1</Version>\n    </PackageReference>\n    <PackageReference Include=\"xunit.runner.console\">\n      <Version>2.4.1</Version>\n      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>\n      <PrivateAssets>all</PrivateAssets>\n    </PackageReference>\n  </ItemGroup>\n</Project>\n"
  },
  {
    "path": "LocalizerTest/Network/GitHubModUpdateService.cs",
    "content": "using System;\nusing FluentAssertions;\nusing Localizer.DataModel;\nusing Localizer.Network;\nusing Newtonsoft.Json.Linq;\nusing Xunit;\n\nnamespace LocalizerTest.Network\n{\n    public class GitHubModUpdateServiceTest\n    {\n        private GitHubModUpdate service;\n\n        private JObject releaseInfo;\n\n        public GitHubModUpdateServiceTest()\n        {\n            // From GitHub API doc's example. https://developer.github.com/v3/repos/releases/#get-the-latest-release\n            // Modified the tag_name to b4.3.2.1\n            var jsonString = \"{\\\"url\\\":\\\"https://api.github.com/repos/octocat/Hello-World/releases/1\\\",\\\"html_url\\\":\\\"https://github.com/octocat/Hello-World/releases/v1.0.0\\\",\\\"assets_url\\\":\\\"https://api.github.com/repos/octocat/Hello-World/releases/1/assets\\\",\\\"upload_url\\\":\\\"https://uploads.github.com/repos/octocat/Hello-World/releases/1/assets{?name,label}\\\",\\\"tarball_url\\\":\\\"https://api.github.com/repos/octocat/Hello-World/tarball/v1.0.0\\\",\\\"zipball_url\\\":\\\"https://api.github.com/repos/octocat/Hello-World/zipball/v1.0.0\\\",\\\"id\\\":1,\\\"node_id\\\":\\\"MDc6UmVsZWFzZTE=\\\",\\\"tag_name\\\":\\\"b4.3.2.1\\\",\\\"target_commitish\\\":\\\"master\\\",\\\"name\\\":\\\"v1.0.0\\\",\\\"body\\\":\\\"Description of the release\\\",\\\"draft\\\":false,\\\"prerelease\\\":false,\\\"created_at\\\":\\\"2013-02-27T19:35:32Z\\\",\\\"published_at\\\":\\\"2013-02-27T19:35:32Z\\\",\\\"author\\\":{\\\"login\\\":\\\"octocat\\\",\\\"id\\\":1,\\\"node_id\\\":\\\"MDQ6VXNlcjE=\\\",\\\"avatar_url\\\":\\\"https://github.com/images/error/octocat_happy.gif\\\",\\\"gravatar_id\\\":\\\"\\\",\\\"url\\\":\\\"https://api.github.com/users/octocat\\\",\\\"html_url\\\":\\\"https://github.com/octocat\\\",\\\"followers_url\\\":\\\"https://api.github.com/users/octocat/followers\\\",\\\"following_url\\\":\\\"https://api.github.com/users/octocat/following{/other_user}\\\",\\\"gists_url\\\":\\\"https://api.github.com/users/octocat/gists{/gist_id}\\\",\\\"starred_url\\\":\\\"https://api.github.com/users/octocat/starred{/owner}{/repo}\\\",\\\"subscriptions_url\\\":\\\"https://api.github.com/users/octocat/subscriptions\\\",\\\"organizations_url\\\":\\\"https://api.github.com/users/octocat/orgs\\\",\\\"repos_url\\\":\\\"https://api.github.com/users/octocat/repos\\\",\\\"events_url\\\":\\\"https://api.github.com/users/octocat/events{/privacy}\\\",\\\"received_events_url\\\":\\\"https://api.github.com/users/octocat/received_events\\\",\\\"type\\\":\\\"User\\\",\\\"site_admin\\\":false},\\\"assets\\\":[{\\\"url\\\":\\\"https://api.github.com/repos/octocat/Hello-World/releases/assets/1\\\",\\\"browser_download_url\\\":\\\"https://github.com/octocat/Hello-World/releases/download/v1.0.0/example.zip\\\",\\\"id\\\":1,\\\"node_id\\\":\\\"MDEyOlJlbGVhc2VBc3NldDE=\\\",\\\"name\\\":\\\"example.zip\\\",\\\"label\\\":\\\"short description\\\",\\\"state\\\":\\\"uploaded\\\",\\\"content_type\\\":\\\"application/zip\\\",\\\"size\\\":1024,\\\"download_count\\\":42,\\\"created_at\\\":\\\"2013-02-27T19:35:32Z\\\",\\\"updated_at\\\":\\\"2013-02-27T19:35:32Z\\\",\\\"uploader\\\":{\\\"login\\\":\\\"octocat\\\",\\\"id\\\":1,\\\"node_id\\\":\\\"MDQ6VXNlcjE=\\\",\\\"avatar_url\\\":\\\"https://github.com/images/error/octocat_happy.gif\\\",\\\"gravatar_id\\\":\\\"\\\",\\\"url\\\":\\\"https://api.github.com/users/octocat\\\",\\\"html_url\\\":\\\"https://github.com/octocat\\\",\\\"followers_url\\\":\\\"https://api.github.com/users/octocat/followers\\\",\\\"following_url\\\":\\\"https://api.github.com/users/octocat/following{/other_user}\\\",\\\"gists_url\\\":\\\"https://api.github.com/users/octocat/gists{/gist_id}\\\",\\\"starred_url\\\":\\\"https://api.github.com/users/octocat/starred{/owner}{/repo}\\\",\\\"subscriptions_url\\\":\\\"https://api.github.com/users/octocat/subscriptions\\\",\\\"organizations_url\\\":\\\"https://api.github.com/users/octocat/orgs\\\",\\\"repos_url\\\":\\\"https://api.github.com/users/octocat/repos\\\",\\\"events_url\\\":\\\"https://api.github.com/users/octocat/events{/privacy}\\\",\\\"received_events_url\\\":\\\"https://api.github.com/users/octocat/received_events\\\",\\\"type\\\":\\\"User\\\",\\\"site_admin\\\":false}}]}\";\n\n            releaseInfo = JObject.Parse(jsonString);\n\n            service = new GitHubModUpdate();\n        }\n\n        [Fact]\n        public void GetUpdateInfo_Correct()\n        {\n            var updateInfo = service.GetUpdateInfo(releaseInfo);\n\n            updateInfo.Type.Should().Be(UpdateType.Major);\n            updateInfo.Version.Should().BeEquivalentTo(Version.Parse(\"4.3.2.1\"));\n        }\n\n        [Fact]\n        public void GetDownlaodURL_Correct()\n        {\n            var url = service.GetDownloadURLInternal(releaseInfo);\n\n            url.Should().Be(\"https://github.com/octocat/Hello-World/releases/download/v1.0.0/example.zip\");\n        }\n    }\n}\n"
  },
  {
    "path": "LocalizerTest/Ninject.cs",
    "content": "using System.Linq;\nusing FluentAssertions;\nusing Ninject;\nusing Xunit;\n\nnamespace LocalizerTest\n{\n    public interface IFoo\n    {\n\n    }\n\n    public interface IBar<T> where T : IFoo\n    {\n\n    }\n\n    public sealed class A : IFoo\n    {\n\n    }\n\n    public sealed class B : IFoo\n    {\n\n    }\n\n    public sealed class ABar : IBar<A>\n    {\n\n    }\n\n    public sealed class BBar : IBar<B>\n    {\n\n    }\n\n    public class NinjectTest\n    {\n        private StandardKernel _kernel;\n\n        public NinjectTest()\n        {\n            _kernel = new StandardKernel();\n        }\n\n        [Fact]\n        public void GenericTypeBinding()\n        {\n            _kernel.Bind(typeof(IBar<>)).To<ABar>().InSingletonScope();\n            _kernel.Bind(typeof(IBar<>)).To<BBar>().InSingletonScope();\n\n            var bars = _kernel.GetAll(typeof(IBar<>));\n\n            bars.Count().Should().Be(2);\n        }\n\n        [Fact]\n        public void MultiSingletonBinding()\n        {\n            _kernel.Bind(typeof(IBar<>), typeof(IBar<A>)).To<ABar>().InSingletonScope();\n\n            var abar1 = _kernel.Get(typeof(IBar<>));\n            var abar2 = _kernel.Get<IBar<A>>();\n\n            abar1.GetType().Should().Be(abar2.GetType());\n            abar1.Should().Be(abar2);\n        }\n    }\n}\n"
  },
  {
    "path": "LocalizerTest/NonTest/UpdateLogger.cs",
    "content": "using System.Collections.Generic;\nusing Localizer.Package.Update;\n\nnamespace LocalizerTest.NonTest\n{\n    public sealed class UpdateLogger : IUpdateLogger\n    {\n        public List<string> Added { get; private set; }\n        public List<string> Removed { get; private set; }\n        public List<string> Changed { get; private set; }\n\n        public UpdateLogger()\n        {\n            Added = new List<string>();\n            Removed = new List<string>();\n            Changed = new List<string>();\n        }\n\n        public void Dispose()\n        {\n        }\n\n        public void Init(string name)\n        {\n        }\n\n        public void Add(object content)\n        {\n            Added.Add(content.ToString());\n        }\n\n        public void Remove(object content)\n        {\n            Removed.Add(content.ToString());\n        }\n\n        public void Change(object content)\n        {\n            Changed.Add(content.ToString());\n        }\n    }\n}\n"
  },
  {
    "path": "LocalizerTest/Package/Import/BasicFileImportTest.cs",
    "content": "using System.Collections.Generic;\nusing FluentAssertions;\nusing Localizer.DataModel.Default;\nusing Localizer.Package.Import;\nusing Xunit;\n\nnamespace LocalizerTest.Package.Import\n{\n    public class BasicFileImportTest\n    {\n        [Fact]\n        public void MergeFile_Correct()\n        {\n            var importer = new BasicImporter<BasicItemFile>();\n\n            var main = new BasicItemFile()\n            {\n                Items = new Dictionary<string, ItemEntry>()\n                {\n                    {\n                        \"Key1\", new ItemEntry()\n                        {\n                            Name = new BaseEntry()\n                            {\n                                Origin = \"NameOrigin1\",\n                                Translation = \"NameTranslation1\"\n                            },\n                            Tooltip = new BaseEntry()\n                            {\n                                Origin = \"TooltipOrigin1\",\n                                Translation = \"TooltipTranslation1\"\n                            },\n                        }\n                    },\n                    {\n                        \"Key2\", new ItemEntry()\n                        {\n                            Name = new BaseEntry()\n                            {\n                                Origin = \"NameOrigin2\",\n                                Translation = \"NameTranslation2\"\n                            },\n                            Tooltip = new BaseEntry()\n                            {\n                                Origin = \"TooltipOrigin2\",\n                                Translation = \"\"\n                            },\n                        }\n                    },\n                    {\n                        \"Key3\", new ItemEntry()\n                        {\n                            Name = new BaseEntry()\n                            {\n                                Origin = \"NameOrigin3\",\n                                Translation = \"\"\n                            },\n                            Tooltip = new BaseEntry()\n                            {\n                                Origin = \"TooltipOrigin3\",\n                                Translation = \"\"\n                            },\n                        }\n                    },\n                }\n            };\n\n            var addition = new BasicItemFile()\n            {\n                Items = new Dictionary<string, ItemEntry>()\n                {\n                    {\n                        \"Key1\", new ItemEntry()\n                        {\n                            Name = new BaseEntry()\n                            {\n                                Origin = \"NameOrigin1\",\n                                Translation = \"AnotherNameTranslation1\"\n                            },\n                            Tooltip = new BaseEntry()\n                            {\n                                Origin = \"TooltipOrigin1\",\n                                Translation = \"AnotherTooltipTranslation1\"\n                            },\n                        }\n                    },\n                    {\n                        \"Key2\", new ItemEntry()\n                        {\n                            Name = new BaseEntry()\n                            {\n                                Origin = \"NameOrigin2\",\n                                Translation = \"\"\n                            },\n                            Tooltip = new BaseEntry()\n                            {\n                                Origin = \"TooltipOrigin2\",\n                                Translation = \"AnotherTooltipTranslation2\"\n                            },\n                        }\n                    },\n                    {\n                        \"Key3\", new ItemEntry()\n                        {\n                            Name = new BaseEntry()\n                            {\n                                Origin = \"NameOrigin3\",\n                                Translation = \"AnotherNameTranslation3\"\n                            },\n                            Tooltip = new BaseEntry()\n                            {\n                                Origin = \"TooltipOrigin3\",\n                                Translation = \"AnotherTooltipTranslation3\"\n                            },\n                        }\n                    },\n                    {\n                        \"Key4\", new ItemEntry()\n                        {\n                            Name = new BaseEntry()\n                            {\n                                Origin = \"NameOrigin4\",\n                                Translation = \"NameTranslation4\"\n                            },\n                            Tooltip = new BaseEntry()\n                            {\n                                Origin = \"TooltipOrigin4\",\n                                Translation = \"TooltipTranslation4\"\n                            },\n                        }\n                    },\n                }\n            };\n\n            var result = importer.MergeInternal(main, addition);\n\n            result.Items.Count.Should().Be(4);\n\n            result.Items[\"Key1\"].Name.Translation.Should().Be(\"NameTranslation1\");\n            result.Items[\"Key1\"].Tooltip.Translation.Should().Be(\"TooltipTranslation1\");\n\n            result.Items[\"Key4\"].Name.Origin.Should().Be(\"NameOrigin4\");\n            result.Items[\"Key4\"].Name.Translation.Should().Be(\"NameTranslation4\");\n            result.Items[\"Key4\"].Tooltip.Origin.Should().Be(\"TooltipOrigin4\");\n            result.Items[\"Key4\"].Tooltip.Translation.Should().Be(\"TooltipTranslation4\");\n\n            result.Items[\"Key2\"].Name.Translation.Should().Be(\"NameTranslation2\");\n            result.Items[\"Key2\"].Tooltip.Translation.Should().Be(\"AnotherTooltipTranslation2\");\n\n            result.Items[\"Key3\"].Name.Translation.Should().Be(\"AnotherNameTranslation3\");\n            result.Items[\"Key3\"].Tooltip.Translation.Should().Be(\"AnotherTooltipTranslation3\");\n        }\n\n        [Fact]\n        public void MergeEntry_Correct()\n        {\n            var service = new BasicImporter<BasicItemFile>();\n\n            var main1 = new ItemEntry()\n            {\n                Name = new BaseEntry()\n                {\n                    Origin = \"NameOrigin\",\n                    Translation = \"NameTranslation\"\n                },\n                Tooltip = new BaseEntry()\n                {\n                    Origin = \"TooltipOrigin\",\n                    Translation = \"TooltipTranslation\"\n                },\n            };\n            var addition1 = new ItemEntry()\n            {\n                Name = new BaseEntry()\n                {\n                    Origin = \"NameOrigin\",\n                    Translation = \"AnotherNameTranslation\"\n                },\n                Tooltip = new BaseEntry()\n                {\n                    Origin = \"TooltipOrigin\",\n                    Translation = \"AnotherTooltipTranslation\"\n                },\n            };\n\n            var result1 = service.Merge(main1, addition1) as ItemEntry;\n            result1.Name.Translation.Should().Be(\"NameTranslation\");\n            result1.Tooltip.Translation.Should().Be(\"TooltipTranslation\");\n\n            var main2 = new ItemEntry()\n            {\n                Name = new BaseEntry()\n                {\n                    Origin = \"NameOrigin\",\n                    Translation = \"\"\n                },\n                Tooltip = new BaseEntry()\n                {\n                    Origin = \"TooltipOrigin\",\n                    Translation = \"\"\n                },\n            };\n            var addition2 = new ItemEntry()\n            {\n                Name = new BaseEntry()\n                {\n                    Origin = \"NameOrigin\",\n                    Translation = \"AnotherNameTranslation\"\n                },\n                Tooltip = new BaseEntry()\n                {\n                    Origin = \"TooltipOrigin\",\n                    Translation = \"AnotherTooltipTranslation\"\n                },\n            };\n\n            var result2 = service.Merge(main2, addition2) as ItemEntry;\n            result2.Name.Translation.Should().Be(\"AnotherNameTranslation\");\n            result2.Tooltip.Translation.Should().Be(\"AnotherTooltipTranslation\");\n\n\n            var main3 = new ItemEntry()\n            {\n                Name = new BaseEntry()\n                {\n                    Origin = \"NameOrigin\",\n                    Translation = \"NameTranslation\"\n                },\n                Tooltip = new BaseEntry()\n                {\n                    Origin = \"TooltipOrigin\",\n                    Translation = \"\"\n                },\n            };\n            var addition3 = new ItemEntry()\n            {\n                Name = new BaseEntry()\n                {\n                    Origin = \"NameOrigin\",\n                    Translation = \"AnotherNameTranslation\"\n                },\n                Tooltip = new BaseEntry()\n                {\n                    Origin = \"TooltipOrigin\",\n                    Translation = \"AnotherTooltipTranslation\"\n                },\n            };\n\n            var result3 = service.Merge(main3, addition3) as ItemEntry;\n            result3.Name.Translation.Should().Be(\"NameTranslation\");\n            result3.Tooltip.Translation.Should().Be(\"AnotherTooltipTranslation\");\n        }\n    }\n}\n"
  },
  {
    "path": "LocalizerTest/Package/Import/CustomModTranslationFileImportTest.cs",
    "content": "using System.Collections.Generic;\nusing FluentAssertions;\nusing Localizer.DataModel.Default;\nusing Localizer.Package.Import;\nusing Xunit;\n\nnamespace LocalizerTest.Package.Import\n{\n    public class CustomModTranslationFileImportTest\n    {\n        [Fact]\n        public void Merge_Correct()\n        {\n            var importer = new CustomModTranslationImporter();\n\n            var main = new CustomModTranslationFile()\n            {\n                Translations = new Dictionary<string, BaseEntry>()\n                {\n                    { \"Key1\", new BaseEntry(){ Origin = \"Origin1\", Translation = \"Translation1\" } },\n                    { \"Key2\", new BaseEntry(){ Origin = \"Origin2\", Translation = \"Translation2\" } },\n                    { \"Key3\", new BaseEntry(){ Origin = \"Origin3\", Translation = \"Translation3\" } },\n                }\n            };\n\n            var addition = new CustomModTranslationFile()\n            {\n                Translations = new Dictionary<string, BaseEntry>()\n                {\n                    { \"Key1\", new BaseEntry(){ Origin = \"Origin1\", Translation = \"AnotherTranslation1\" } },\n                    { \"Key4\", new BaseEntry(){ Origin = \"Origin4\", Translation = \"Translation4\" } },\n                }\n            };\n\n            var result = importer.MergeInternal(main, addition);\n\n            result.Translations.Count.Should().Be(4);\n            result.Translations[\"Key1\"].Translation.Should().Be(\"Translation1\");\n            result.Translations[\"Key4\"].Origin.Should().Be(\"Origin4\");\n            result.Translations[\"Key4\"].Translation.Should().Be(\"Translation4\");\n        }\n    }\n}\n"
  },
  {
    "path": "LocalizerTest/Package/Import/LdstrFileImportBaseTest.cs",
    "content": "using System.Collections.Generic;\nusing FluentAssertions;\nusing Localizer.DataModel.Default;\nusing Localizer.Package.Import;\nusing Xunit;\n\nnamespace LocalizerTest.Package.Import\n{\n    public class LdstrFileImportBaseTest\n    {\n        [Fact]\n        public void MergeEntry_Correct()\n        {\n            var service = new HarmonyLdstrImporter();\n\n            var main = new LdstrEntry()\n            {\n                Instructions = new List<BaseEntry>()\n                {\n                    new BaseEntry()\n                    {\n                        Origin = \"Origin1\",\n                        Translation = \"Translation1\"\n                    },\n                    new BaseEntry()\n                    {\n                        Origin = \"Origin2\",\n                        Translation = \"Translation2\"\n                    },\n                }\n            };\n\n            var addition = new LdstrEntry()\n            {\n                Instructions = new List<BaseEntry>()\n                {\n                    new BaseEntry()\n                    {\n                        Origin = \"Origin1\",\n                        Translation = \"AnotherTranslation1\"\n                    },\n                    new BaseEntry()\n                    {\n                        Origin = \"AnotherOrigin2\",\n                        Translation = \"Translation2\"\n                    },\n                    new BaseEntry()\n                    {\n                        Origin = \"Origin3\",\n                        Translation = \"Translation3\"\n                    },\n                }\n            };\n\n            var result = service.Merge(main, addition);\n\n            result.Instructions.Count.Should().Be(4);\n\n            result.Instructions.Should().ContainSingle(i => i.Origin == \"Origin1\" && i.Translation == \"Translation1\");\n            result.Instructions.Should().ContainSingle(i => i.Origin == \"Origin2\" && i.Translation == \"Translation2\");\n            result.Instructions.Should().ContainSingle(i => i.Origin == \"AnotherOrigin2\" && i.Translation == \"Translation2\");\n            result.Instructions.Should().ContainSingle(i => i.Origin == \"Origin3\" && i.Translation == \"Translation3\");\n        }\n\n        [Fact]\n        public void MergeFile_Correct()\n        {\n            var importer = new HarmonyLdstrImporter();\n\n            var main = new LdstrFile()\n            {\n                LdstrEntries = new Dictionary<string, LdstrEntry>()\n                {\n                    { \"Key1\", new LdstrEntry()\n                        {\n                            Instructions = new List<BaseEntry>()\n                            {\n                                new BaseEntry(){ Origin = \"Origin1\", Translation = \"Translation1\"},\n                                new BaseEntry(){ Origin = \"Origin2\", Translation = \"Translation2\"},\n                            }\n                        }\n                    },\n                    { \"Key2\", new LdstrEntry()\n                        {\n                            Instructions = new List<BaseEntry>()\n                            {\n                                new BaseEntry(){ Origin = \"Origin3\", Translation = \"Translation3\"},\n                                new BaseEntry(){ Origin = \"Origin4\", Translation = \"Translation4\"},\n                            }\n                        }\n                    },\n                }\n            };\n\n            var addition = new LdstrFile()\n            {\n                LdstrEntries = new Dictionary<string, LdstrEntry>()\n                {\n                    { \"Key1\", new LdstrEntry()\n                        {\n                            Instructions = new List<BaseEntry>()\n                            {\n                                new BaseEntry(){ Origin = \"Origin1\", Translation = \"AnotherTranslation1\"},\n                                new BaseEntry(){ Origin = \"AnotherOrigin1\", Translation = \"Translation1\"},\n                                new BaseEntry(){ Origin = \"Origin5\", Translation = \"Translation5\"},\n                            }\n                        }\n                    },\n                    { \"Key3\", new LdstrEntry()\n                        {\n                            Instructions = new List<BaseEntry>()\n                            {\n                                new BaseEntry(){ Origin = \"Origin6\", Translation = \"Translation6\"}\n                            }\n                        }\n                    },\n                }\n            };\n\n            var result = importer.MergeInternal(main, addition);\n\n            result.LdstrEntries.Count.Should().Be(3);\n\n            result.LdstrEntries[\"Key1\"].Instructions.Should().ContainSingle(i => i.Origin == \"Origin1\" && i.Translation == \"Translation1\");\n            result.LdstrEntries[\"Key1\"].Instructions.Should().ContainSingle(i => i.Origin == \"AnotherOrigin1\" && i.Translation == \"Translation1\");\n            result.LdstrEntries[\"Key1\"].Instructions.Should().ContainSingle(i => i.Origin == \"Origin5\" && i.Translation == \"Translation5\");\n\n            result.LdstrEntries[\"Key3\"].Instructions.Count.Should().Be(1);\n            result.LdstrEntries[\"Key3\"].Instructions[0].Origin.Should().Be(\"Origin6\");\n            result.LdstrEntries[\"Key3\"].Instructions[0].Translation.Should().Be(\"Translation6\");\n        }\n    }\n}\n"
  },
  {
    "path": "LocalizerTest/Package/Update/BasicFileUpdateTest.cs",
    "content": "using System.Collections.Generic;\nusing FluentAssertions;\nusing Localizer.DataModel.Default;\nusing Localizer.Package.Update;\nusing LocalizerTest.NonTest;\nusing Xunit;\n\nnamespace LocalizerTest.Package.Update\n{\n    public class BasicFileUpdateTest\n    {\n        [Fact]\n        public void UpdateFile_Correct()\n        {\n            var service = new BasicFileUpdater<BasicItemFile>();\n\n            var logger = new UpdateLogger();\n\n            var oldFile = new BasicItemFile()\n            {\n                Items = new Dictionary<string, ItemEntry>()\n                {\n                    {\n                        \"Key1\", new ItemEntry()\n                        {\n                            Name = new BaseEntry()\n                            {\n                                Origin = \"NameOrigin1\",\n                                Translation = \"NameTranslation1\"\n                            },\n                            Tooltip = new BaseEntry()\n                            {\n                                Origin = \"TooltipOrigin1\",\n                                Translation = \"TooltipTranslation1\"\n                            },\n                        }\n                    },\n                    {\n                        \"Key2\", new ItemEntry()\n                        {\n                            Name = new BaseEntry()\n                            {\n                                Origin = \"NameOrigin2\",\n                                Translation = \"NameTranslation2\"\n                            },\n                            Tooltip = new BaseEntry()\n                            {\n                                Origin = \"TooltipOrigin2\",\n                                Translation = \"TooltipTranslation2\"\n                            },\n                        }\n                    },\n                    {\n                        \"Key3\", new ItemEntry()\n                        {\n                            Name = new BaseEntry()\n                            {\n                                Origin = \"NameOrigin3\",\n                                Translation = \"NameTranslation3\"\n                            },\n                            Tooltip = new BaseEntry()\n                            {\n                                Origin = \"TooltipOrigin3\",\n                                Translation = \"TooltipTranslation3\"\n                            },\n                        }\n                    },\n                }\n            };\n\n            var newFile = new BasicItemFile()\n            {\n                Items = new Dictionary<string, ItemEntry>()\n                {\n                    {\n                        \"Key1\", new ItemEntry()\n                        {\n                            Name = new BaseEntry()\n                            {\n                                Origin = \"AnotherNameOrigin1\",\n                                Translation = \"AnotherNameTranslation1\"\n                            },\n                            Tooltip = new BaseEntry()\n                            {\n                                Origin = \"AnotherTooltipOrigin1\",\n                                Translation = \"AnotherTooltipTranslation1\"\n                            },\n                        }\n                    },\n                    {\n                        \"Key3\", new ItemEntry()\n                        {\n                            Name = new BaseEntry()\n                            {\n                                Origin = \"NameOrigin3\",\n                                Translation = \"AnotherNameTranslation3\"\n                            },\n                            Tooltip = new BaseEntry()\n                            {\n                                Origin = \"TooltipOrigin3\",\n                                Translation = \"AnotherTooltipTranslation3\"\n                            },\n                        }\n                    },\n                    {\n                        \"Key4\", new ItemEntry()\n                        {\n                            Name = new BaseEntry()\n                            {\n                                Origin = \"NameOrigin4\",\n                                Translation = \"NameTranslation4\"\n                            },\n                            Tooltip = new BaseEntry()\n                            {\n                                Origin = \"TooltipOrigin4\",\n                                Translation = \"TooltipTranslation4\"\n                            },\n                        }\n                    },\n                }\n            };\n\n            service.Update(oldFile, newFile, logger);\n\n            logger.Added.Count.Should().Be(1);\n            logger.Changed.Count.Should().Be(2);\n            logger.Removed.Count.Should().Be(1);\n\n            oldFile.Items.Count.Should().Be(4);\n            oldFile.Items[\"Key1\"].Name.Origin.Should().Be(\"AnotherNameOrigin1\");\n            oldFile.Items[\"Key1\"].Name.Translation.Should().Be(\"AnotherNameTranslation1\");\n            oldFile.Items[\"Key1\"].Tooltip.Origin.Should().Be(\"AnotherTooltipOrigin1\");\n            oldFile.Items[\"Key1\"].Tooltip.Translation.Should().Be(\"AnotherTooltipTranslation1\");\n            oldFile.Items[\"Key3\"].Name.Origin.Should().Be(\"NameOrigin3\");\n            oldFile.Items[\"Key3\"].Name.Translation.Should().Be(\"NameTranslation3\");\n            oldFile.Items[\"Key3\"].Tooltip.Origin.Should().Be(\"TooltipOrigin3\");\n            oldFile.Items[\"Key3\"].Tooltip.Translation.Should().Be(\"TooltipTranslation3\");\n            oldFile.Items[\"Key4\"].Name.Origin.Should().Be(\"NameOrigin4\");\n            oldFile.Items[\"Key4\"].Name.Translation.Should().Be(\"NameTranslation4\");\n            oldFile.Items[\"Key4\"].Tooltip.Origin.Should().Be(\"TooltipOrigin4\");\n            oldFile.Items[\"Key4\"].Tooltip.Translation.Should().Be(\"TooltipTranslation4\");\n        }\n\n        [Fact]\n        public void UpdateEntry_Correct()\n        {\n            var service = new BasicFileUpdater<BasicItemFile>();\n            var logger1 = new UpdateLogger();\n\n            var oldEntry1 = new ItemEntry()\n            {\n                Name = new BaseEntry()\n                {\n                    Origin = \"NameOrigin\",\n                    Translation = \"NameTranslation\"\n                },\n                Tooltip = new BaseEntry()\n                {\n                    Origin = \"TooltipOrigin\",\n                    Translation = \"TooltipTranslation\"\n                },\n            };\n\n            var newEntry1 = new ItemEntry()\n            {\n                Name = new BaseEntry()\n                {\n                    Origin = \"AnotherNameOrigin\",\n                    Translation = \"AnotherNameTranslation\"\n                },\n                Tooltip = new BaseEntry()\n                {\n                    Origin = \"AnotherTooltipOrigin\",\n                    Translation = \"AnotherTooltipTranslation\"\n                },\n            };\n\n            service.UpdateEntry(\"Key\", oldEntry1, newEntry1, logger1);\n\n            logger1.Changed.Count.Should().Be(2);\n            oldEntry1.Name.Origin.Should().Be(\"AnotherNameOrigin\");\n            oldEntry1.Name.Translation.Should().Be(\"AnotherNameTranslation\");\n            oldEntry1.Tooltip.Origin.Should().Be(\"AnotherTooltipOrigin\");\n            oldEntry1.Tooltip.Translation.Should().Be(\"AnotherTooltipTranslation\");\n\n\n            var logger2 = new UpdateLogger();\n\n            var oldEntry2 = new ItemEntry()\n            {\n                Name = new BaseEntry()\n                {\n                    Origin = \"NameOrigin\",\n                    Translation = \"NameTranslation\"\n                },\n                Tooltip = new BaseEntry()\n                {\n                    Origin = \"TooltipOrigin\",\n                    Translation = \"TooltipTranslation\"\n                },\n            };\n\n            var newEntry2 = new ItemEntry()\n            {\n                Name = new BaseEntry()\n                {\n                    Origin = \"NameOrigin\",\n                    Translation = \"AnotherNameTranslation\"\n                },\n                Tooltip = new BaseEntry()\n                {\n                    Origin = \"TooltipOrigin\",\n                    Translation = \"AnotherTooltipTranslation\"\n                },\n            };\n\n            service.UpdateEntry(\"Key\", oldEntry2, newEntry2, logger2);\n\n            logger2.Changed.Count.Should().Be(0);\n            oldEntry2.Name.Origin.Should().Be(\"NameOrigin\");\n            oldEntry2.Name.Translation.Should().Be(\"NameTranslation\");\n            oldEntry2.Tooltip.Origin.Should().Be(\"TooltipOrigin\");\n            oldEntry2.Tooltip.Translation.Should().Be(\"TooltipTranslation\");\n        }\n    }\n}\n"
  },
  {
    "path": "LocalizerTest/Package/Update/CustomModTranslationFileUpdateTest.cs",
    "content": "using System.Collections.Generic;\nusing FluentAssertions;\nusing Localizer.DataModel.Default;\nusing Localizer.Package.Update;\nusing LocalizerTest.NonTest;\nusing Xunit;\n\nnamespace LocalizerTest.Package.Update\n{\n    public class CustomModTranslationFileUpdateTest\n    {\n        [Fact]\n        public void Update_Correct()\n        {\n            var service = new CustomModTranslationUpdater();\n            var logger = new UpdateLogger();\n\n            var oldFile = new CustomModTranslationFile()\n            {\n                Translations = new Dictionary<string, BaseEntry>()\n                {\n                    { \"Key1\", new BaseEntry(){ Origin = \"Origin1\", Translation = \"Translation1\" } },\n                    { \"Key2\", new BaseEntry(){ Origin = \"Origin2\", Translation = \"Translation2\" } },\n                    { \"Key3\", new BaseEntry(){ Origin = \"Origin3\", Translation = \"Translation3\" } },\n                }\n            };\n\n            var newFile = new CustomModTranslationFile()\n            {\n                Translations = new Dictionary<string, BaseEntry>()\n                {\n                    { \"Key1\", new BaseEntry(){ Origin = \"AnotherOrigin1\", Translation = \"AnotherTranslation1\" } },\n                    { \"Key4\", new BaseEntry(){ Origin = \"Origin4\", Translation = \"Translation4\" } },\n                    { \"Key5\", new BaseEntry(){ Origin = \"Origin5\", Translation = \"Translation5\" } },\n                }\n            };\n\n            service.Update(oldFile, newFile, logger);\n\n            logger.Added.Count.Should().Be(2);\n            logger.Removed.Count.Should().Be(2);\n            logger.Changed.Count.Should().Be(1);\n\n            oldFile.Translations.Count.Should().Be(5);\n            oldFile.Translations[\"Key1\"].Origin.Should().Be(\"AnotherOrigin1\");\n            oldFile.Translations[\"Key1\"].Translation.Should().Be(\"AnotherTranslation1\");\n            oldFile.Translations[\"Key2\"].Origin.Should().Be(\"Origin2\");\n            oldFile.Translations[\"Key2\"].Translation.Should().Be(\"Translation2\");\n            oldFile.Translations[\"Key3\"].Origin.Should().Be(\"Origin3\");\n            oldFile.Translations[\"Key3\"].Translation.Should().Be(\"Translation3\");\n            oldFile.Translations[\"Key4\"].Origin.Should().Be(\"Origin4\");\n            oldFile.Translations[\"Key4\"].Translation.Should().Be(\"Translation4\");\n            oldFile.Translations[\"Key5\"].Origin.Should().Be(\"Origin5\");\n            oldFile.Translations[\"Key5\"].Translation.Should().Be(\"Translation5\");\n        }\n    }\n}\n"
  },
  {
    "path": "LocalizerTest/Package/Update/LdstrFileUpdateTest.cs",
    "content": "using System.Collections.Generic;\nusing FluentAssertions;\nusing Localizer.DataModel.Default;\nusing Localizer.Package.Update;\nusing LocalizerTest.NonTest;\nusing Xunit;\n\nnamespace LocalizerTest.Package.Update\n{\n    public class LdstrFileUpdateTest\n    {\n        [Fact]\n        public void Update_Correct()\n        {\n            var service = new LdstrFileUpdater();\n\n            var logger = new UpdateLogger();\n\n            var oldFile = new LdstrFile()\n            {\n                LdstrEntries = new Dictionary<string, LdstrEntry>()\n                {\n                    { \"Key1\", new LdstrEntry()\n                        {\n                            Instructions = new List<BaseEntry>()\n                            {\n                                new BaseEntry(){ Origin = \"Origin1\", Translation = \"Translation1\"},\n                                new BaseEntry(){ Origin = \"Origin2\", Translation = \"Translation2\"},\n                            }\n                        }\n                    },\n                    { \"Key2\", new LdstrEntry()\n                        {\n                            Instructions = new List<BaseEntry>()\n                            {\n                                new BaseEntry(){ Origin = \"Origin3\", Translation = \"Translation3\"},\n                                new BaseEntry(){ Origin = \"Origin4\", Translation = \"Translation4\"},\n                            }\n                        }\n                    },\n                }\n            };\n\n            var newFile = new LdstrFile()\n            {\n                LdstrEntries = new Dictionary<string, LdstrEntry>()\n                {\n                    { \"Key1\", new LdstrEntry()\n                        {\n                            Instructions = new List<BaseEntry>()\n                            {\n                                new BaseEntry(){ Origin = \"Origin1\", Translation = \"\"},\n                                new BaseEntry(){ Origin = \"AnotherOrigin1\", Translation = \"\"},\n                                new BaseEntry(){ Origin = \"Origin5\", Translation = \"\"},\n                            }\n                        }\n                    },\n                    { \"Key3\", new LdstrEntry()\n                        {\n                            Instructions = new List<BaseEntry>()\n                            {\n                                new BaseEntry(){ Origin = \"Origin6\", Translation = \"\"}\n                            }\n                        }\n                    },\n                }\n            };\n\n            service.Update(oldFile, newFile, logger);\n\n            logger.Added.Count.Should().Be(1);\n            logger.Changed.Count.Should().Be(2);\n            logger.Added.Count.Should().Be(1);\n\n            oldFile.LdstrEntries.Count.Should().Be(3);\n\n            oldFile.LdstrEntries[\"Key1\"].Instructions.Count.Should().Be(4);\n            oldFile.LdstrEntries[\"Key1\"].Instructions.Should().ContainSingle(i => i.Origin == \"Origin1\" && i.Translation == \"Translation1\");\n            oldFile.LdstrEntries[\"Key1\"].Instructions.Should().ContainSingle(i => i.Origin == \"Origin2\" && i.Translation == \"Translation2\");\n            oldFile.LdstrEntries[\"Key1\"].Instructions.Should().ContainSingle(i => i.Origin == \"AnotherOrigin1\" && i.Translation == \"\");\n            oldFile.LdstrEntries[\"Key1\"].Instructions.Should().ContainSingle(i => i.Origin == \"Origin5\" && i.Translation == \"\");\n\n            oldFile.LdstrEntries[\"Key2\"].Instructions.Count.Should().Be(2);\n            oldFile.LdstrEntries[\"Key2\"].Instructions.Should().ContainSingle(i => i.Origin == \"Origin3\" && i.Translation == \"Translation3\");\n            oldFile.LdstrEntries[\"Key2\"].Instructions.Should().ContainSingle(i => i.Origin == \"Origin4\" && i.Translation == \"Translation4\");\n\n            oldFile.LdstrEntries[\"Key3\"].Instructions.Count.Should().Be(1);\n            oldFile.LdstrEntries[\"Key3\"].Instructions.Should().ContainSingle(i => i.Origin == \"Origin6\" && i.Translation == \"\");\n        }\n    }\n}\n"
  },
  {
    "path": "ModPatch/ModPatch.csproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project Sdk=\"Microsoft.NET.Sdk\">\n  <Import Project=\"$(USERPROFILE)\\Documents\\My Games\\Terraria\\ModLoader\\references\\tModLoader.targets\" />\n  <PropertyGroup>\n    <OutputType>Exe</OutputType>\n    <RootNamespace>ModPatch</RootNamespace>\n    <AssemblyName>ModPatch</AssemblyName>\n    <TargetFramework>net472</TargetFramework>\n    <PlatformTarget>x86</PlatformTarget>\n    <LangVersion>7.3</LangVersion>\n  </PropertyGroup>\n</Project>"
  },
  {
    "path": "ModPatch/Program.cs",
    "content": "using System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Security.Cryptography;\nusing System.Text;\n\nnamespace ModPatch\n{\n    internal class Program\n    {\n        private static void Main(string[] args)\n        {\n            var FILE_PATH = Environment.ExpandEnvironmentVariables(@\"%USERPROFILE%\\Documents\\My Games\\Terraria\\ModLoader\\Mods\\Localizer.tmod\");\n            var tModLoaderVersion = \"\";\n            var modName = \"\";\n            var modVersion = \"\";\n            var files = new List<(string fileName, int length, int compressedLength, byte[] content)>();\n\n            using (var fileStream = File.OpenRead(FILE_PATH))\n            {\n                using (var br = new BinaryReader(fileStream))\n                {\n                    br.ReadBytes(4); // TMOD\n                    tModLoaderVersion = br.ReadString(); // tModLoader version\n                    br.ReadBytes(280); // Signature\n                    modName = br.ReadString(); // Name\n                    modVersion = br.ReadString(); // Version\n                    var fileCount = br.ReadInt32();\n                    for (var i = 0; i < fileCount; i++)\n                    {\n                        var entry = (filename: br.ReadString(), length: br.ReadInt32(),\n                                     compressedLength: br.ReadInt32(),\n                                     content: new byte[] { });\n                        files.Add(entry);\n                    }\n\n                    for (var i = 0; i < fileCount; i++)\n                    {\n                        var file = files[i];\n                        var content = br.ReadBytes(file.compressedLength);\n                        files[i] = (file.fileName, file.length, file.compressedLength, content);\n                    }\n                }\n            }\n\n            if (!modName.StartsWith(\"!\"))\n            {\n                modName = \"!\" + modName;\n            }\n\n            files = files.Select(f => (f.fileName.EndsWith(\"NA.dll\") && !f.fileName.StartsWith(\"!\"))\n                                     ? (\"!\" + f.fileName, f.length, f.compressedLength, f.content)\n                                     : f).ToList();\n\n            using (var fileStream = new FileStream(FILE_PATH, FileMode.Create, FileAccess.ReadWrite))\n            {\n                using (var bw = new BinaryWriter(fileStream))\n                {\n                    bw.Write(Encoding.UTF8.GetBytes(\"TMOD\"));\n                    bw.Write(tModLoaderVersion);\n                    var hashPos = bw.BaseStream.Position;\n                    bw.Seek(280, SeekOrigin.Current);\n                    var contentPos = bw.BaseStream.Position;\n                    bw.Write(modName);\n                    bw.Write(modVersion);\n                    bw.Write(files.Count);\n                    foreach (var file in files)\n                    {\n                        bw.Write(file.fileName);\n                        bw.Write(file.length);\n                        bw.Write(file.compressedLength);\n                    }\n                    foreach (var file in files)\n                    {\n                        bw.Write(file.content);\n                    }\n                    bw.Seek((int)contentPos, SeekOrigin.Begin);\n                    var hash = SHA1.Create().ComputeHash(bw.BaseStream);\n                    bw.Seek((int)hashPos, SeekOrigin.Begin);\n                    bw.Write(hash);\n                }\n            }\n\n            var enabledFilePath =\n                Environment.ExpandEnvironmentVariables(\n                    @\"%USERPROFILE%\\Documents\\My Games\\Terraria\\ModLoader\\Mods\\enabled.json\");\n\n            if (!File.Exists(enabledFilePath))\n            {\n                return;\n            }\n\n            File.WriteAllText(enabledFilePath, File.ReadAllText(enabledFilePath).Replace(\"\\\"Localizer\\\"\", \"\\\"!Localizer\\\"\"));\n        }\n    }\n}\n"
  },
  {
    "path": "README.md",
    "content": "# Localizer Mod\n\n![](https://github.com/chi-rei-den/Localizer/workflows/Mod%20Build/badge.svg)\n![](https://github.com/chi-rei-den/Localizer/workflows/Unit%20Test/badge.svg)\n\n### 下载与说明请点击下方链接\n\n#### [简体中文](https://github.com/chi-rei-den/Localizer/wiki/%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)\n\n## Credits\n\n* [JetBrains](https://www.jetbrains.com/): Free license for this project.\n"
  }
]