惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

F
Fortinet All Blogs
WordPress大学
WordPress大学
The Cloudflare Blog
云风的 BLOG
云风的 BLOG
博客园 - Franky
D
Docker
小众软件
小众软件
阮一峰的网络日志
阮一峰的网络日志
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Engineering at Meta
Engineering at Meta
MongoDB | Blog
MongoDB | Blog
U
Unit 42
M
MIT News - Artificial intelligence
B
Blog
GbyAI
GbyAI
C
Check Point Blog
P
Proofpoint News Feed
博客园 - 司徒正美
Hugging Face - Blog
Hugging Face - Blog
雷峰网
雷峰网
IT之家
IT之家
Google DeepMind News
Google DeepMind News
V
V2EX
Stack Overflow Blog
Stack Overflow Blog

Giscafer's blog

博客停更说明 使用 ViewContainerRef 探索Angular DOM操作 GIS520论坛关闭停止运营 ionic3之组件封装篇 ionic3开发遇到的一些问题及解决方法 ionic3之自定义tabs菜单图标 ionic3 之Android的actionsheet渲染和ios一致 Hexo博客畅言评论插件试用 从GISer到互联网前端工程师,JUST DO IT angular实现IM聊天图片发送 Cafe主题v1.0发布 React搭建百度前端技术学院习题演示SPA react-ponitor React 与 Redux 实践 —— 城市筛选面板 1.Two Sum 如何组件化开发WebGIS系统 2016年末总结 代码理解React组件生命周期过程 hexo-theme-cafe
ionic3之图片选择插件com.synconset.imagepicker
2017-07-04 · via Giscafer's blog

com.synconset.imagepicker插件是telerik团队开发提供。

使用命令安装 ionic cordova plugin add cordova-plugin-image-picker

安装后需要修改中文支持。

Android

multiimagechooser_strings_en.xml文件修改

1

2

3

4

5

6

7

8

9

10

11

12

<?xml version="1.0" encoding="utf-8"?>

<resources>

<string name="multi_app_name">图片选择器</string>

<string name="free_version_label">还可以选择 %d 张图片</string>

<string name="error_database">打开图像数据库时出错,请反馈问题.</string>

<string name="requesting_thumbnails">请求缩略图,请耐心等待</string>

<string name="multi_image_picker_processing_images_title">正在处理...</string>

<string name="multi_image_picker_processing_images_message">请稍等...</string>

<string name="discard" translatable="false">取消</string>

<string name="done" translatable="false">确定</string>

</resources>

直接用上边代码覆盖xx_project\plugins\com.synconset.imagepicker\src\android\Library\res\values\multiimagechooser_strings_en.xml文件中的东西。

MultiImageChooserActivity.java 弹窗汉化修改

工程\plugins\com.synconset.imagepicker\src\android\Library\src\MultiImageChooserActivity.java

用下边代码覆盖方法onItemClick中的对应代码(Line 199):

1

2

3

4

5

6

7

8

9

10

11

new AlertDialog.Builder(this)

.setTitle("提示")

.setMessage("您只能选择" + maxImageCount + " 张图片")

.setPositiveButton("知道了", new DialogInterface.OnClickListener() {

public void onClick(DialogInterface dialog, int which) {

dialog.cancel();

}

})

.create()

.show();

IOS

新增文件ImagePicker/src/ios/GMImagePicker/zh-Hans.lproj/GMImagePicker.strings

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

/* Cancel */

"picker.navigation.cancel-button" = "取消";

/* Done */

"picker.navigation.done-button" = "完成";

/* Navigation bar default title */

"picker.navigation.title" = "我的相册";

/* %@ Items Selected */

"picker.selection.multiple-items" = "已选中 %@ 项";

/* %@ Photos Selected */

"picker.selection.multiple-photos" = "已选中 %@ 张照片";

/* %@ Videos Selected */

"picker.selection.multiple-videos" = "已选中 %@ 个视频";

/* 1 Photo Selected */

"picker.selection.single-photo" = "已选中 1 张照片";

/* 1 Video Selected */

"picker.selection.single-video" = "已选中 1 个视频";

/* All photos */

"picker.table.all-photos-label" = "相机胶卷";

/* Smart Albums */

"picker.table.smart-albums-header" = "智能相册";

/* Albums */

"picker.table.user-albums-header" = "相册";

./plugin.xml文件中添加上边文件引入

1

2

3

4

5

6

7

8

9

<resource-file src="src/ios/GMImagePicker/fr.lproj" />

<resource-file src="src/ios/GMImagePicker/it.lproj" />

<resource-file src="src/ios/GMImagePicker/pt.lproj" />

+ <resource-file src="src/ios/GMImagePicker/zh-Hans.lproj" />

<framework src="Accelerate.framework" />

<framework src="Security.framework" />

<framework src="Photos.framework" />

新版本IOS不支持图片张数限制,具体见官方说明。http://plugins.telerik.com/cordova/plugin/imagepicker

总结

注意的是每次移除plugins重新安装插件的话都要修改一次。比较麻烦。其实可以将插件源码修改自己发布插件,这样就不用每次修改了。

github可以搜到别人汉化重新发布的插件,但是是两年前的,一直未更新,质量不敢保证,不怕麻烦就自己动手了。

推荐文章